Documentation

Unity Engine

Download Unity

Unity Engine

Web Requests Profiler module reference

Use the Web Requests Profiler module to inspect the HTTP requests your application sends.
Read time 13 minutesLast updated 2 days ago

The Web Requests Profiler module displays information about the HTTP requests your application sends through
UnityWebRequest
. This includes requests that
System.Net.Http.HttpClient
sends when it uses
UnityHttpMessageHandler
as its message handler. With the CoreCLR scripting backend, the module also records requests that
HttpClient
sends through its default message handler, with fewer details. For more information, refer to Recorded data by request type. The module charts how many requests are in flight and how many bytes they send and receive each frame. It also lists every request in the capture with its status, size, and duration. Use this module to find slow or failing requests, check what your application sends to a server, and check what the server sends back.
This module is active by default. To show or hide it, refer to Activating Profiler modules. The module records a request only if the Profiler is recording when the request starts. Unity records the details of each request, such as its headers, bodies, and timings, when the request finishes. If you stop recording or deactivate the module while a request is in flight, the request list still displays the request, but as an incomplete request without its details.
Important
Profiler captures can contain credentials and personal data from the requests your application sends and receives. For more information, refer to Safeguard sensitive data.

Chart categories

The upper half of the Profiler window displays a Web Requests chart with the following categories:

Chart

Description

Active RequestsThe number of requests in flight during this frame.
Bytes DownThe number of bytes your application received from requests during this frame.
Bytes UpThe number of bytes your application sent in requests during this frame.
The module also registers the Requests Started, Requests Completed, Requests Failed, and Requests Dropped counters in the Web Requests Profiler category. The chart doesn't display these counters, but you can read them from a script with
ProfilerRecorder
while the module is active.

Module details pane toolbar

When you select the Web Requests module, the module details pane displays the requests that Unity recorded during the capture. Use the toolbar to access the following functionality:

Property

Description

ExportSaves the listed requests as a HAR file. For more information, refer to Export requests to a HAR file.
Search fieldFilters the request list by URL, method, status code, content type, or request source.
Details panel toggleShows or hides the details panel for the selected request.

Summary bar

The summary bar displays totals for all requests in the capture. Filtering the request list doesn't change these totals. The summary bar contains the following items:

Property

Description

RequestsThe number of requests in the capture. When you filter the list, the item displays the number of visible requests out of the total. If the Profiler doesn't record some requests, the item also displays the number of dropped requests. For more information, refer to Request limits.
CompletedThe number of requests that finished.
TransferredThe total number of bytes sent and received. If some requests ran on a platform that doesn't count transferred bytes, the value starts with ≥ to indicate that it's a lower bound.
Pending RequestsThe number of requests still in flight.
Latency p95The duration within which 95% of the finished requests complete. This value doesn't include requests that are still in flight.
ErrorsThe number of requests that failed or that finished with an HTTP status code of 400 or higher.
Total Bytes Down/UpThe total number of bytes received and sent, as separate values.

Request list

The request list displays one row for each request in the capture, in the order the requests started. To sort the list, select a column header. To sort by more than one column, hold Shift and select additional column headers.
When you select a request, the Profiler window jumps to the frame in which that request finished. The details panel, on the right side of the module details pane, displays information about the selected request.
The request list contains the following columns:

Column

Description

# The order in which the requests started.
StatusThe HTTP status code of the response. The column displays ... while the request is in flight, and - if the request finished without a status code. The color of the status code indicates whether the request succeeded, finished with a warning, or failed. Hover over the status code to display its description.
MethodThe HTTP method of the request, such as
GET
or
POST
.
Name/Target DomainThe URL of the request. A warning icon appears next to URLs that use plain HTTP to a server other than the local machine, to indicate that Unity doesn't encrypt the request or the response.
Request SourceThe API that sent the request: UnityWebRequest, or .NET HttpClient for requests that
HttpClient
sends through any message handler.
TypeThe content type of the response.
SizeThe number of bytes received. The column displays — if the platform or message handler doesn't count transferred bytes.
DurationThe time from the start of the request until it finished.

Context menu

Right-click (macOS: Ctrl+click) a request to open a menu with the following options:

Option

Description

Copy URLCopies the URL of the request to the clipboard.
Copy DetailsCopies a summary of the request to the clipboard, including its method, URL, status, source, content type, transferred bytes, and duration.

Details panel

The details panel displays information about the selected request in the following tabs:
Unity records request and response bodies only if their content type is text, such as
text/*
, JSON, XML, JavaScript, or URL-encoded form data (
application/x-www-form-urlencoded
). Unity records up to 16 KB of each body. If a body is longer, the Payload and Response body tabs display the size of the recorded part and the size of the full body. If Unity doesn't record a body, the tab explains why.
If a body has a JSON content type, the tab displays it as an expandable tree. The Payload and Response body tabs have the following buttons:

Button

Description

View SourceDisplays the raw text of the query string or body. Select View Parsed to return to the tree or parameter list.
CopyCopies the raw text of the query string or body to the clipboard.

Headers tab

The Headers tab contains the following sections:

Section

Description

GeneralThe Request URL, Request Method, Status Code, Request Source, Content Type, Transferred bytes, and Duration of the request.
Response HeadersThe headers the server sent in its response.
Request Headers (Configured)The headers your code set on the request.
Request Headers (Wire)The headers that Unity sent to the server, including headers that Unity adds itself, such as a generated
User-Agent
header and cookies. Not all platforms support this section, and the section is empty if the request fails before Unity sends it.
A warning icon appears next to headers whose values are credentials. For more information, refer to Safeguard sensitive data.

Payload tab

The Payload tab appears only when the request has a query string or a request body. It contains the following sections:

Section

Description

Query String ParametersThe name and value of each parameter in the query string of the URL.
Request PayloadThe body your application sent with the request.

Response body tab

The Response body tab displays the body that the server sent in its response.

Timing tab

The Timing tab displays how long each phase of the request took, in milliseconds, as a waterfall chart. If a phase doesn't occur, the tab displays Skipped for that phase. For example, a plain HTTP connection has no Transport Layer Security (TLS) handshake, and a reused connection has no Domain Name System (DNS) lookup. Not all platforms measure the duration of each phase. If the platform doesn't measure phase durations, the tab displays a message instead.
The Timing tab contains the following phases:

Phase

Description

QueueingThe time the request waited before the transfer started.
DNS LookupThe time taken to resolve the host name of the server.
Initial ConnectionThe time taken to open a connection to the server.
TLSThe time taken to complete the TLS handshake for a secure connection.
Request sentThe time taken to prepare and send the request.
Waiting for server responseThe time between sending the request and receiving the first byte of the response.
Content DownloadThe time taken to receive the rest of the response.
Total TimeThe total duration of the request.

Export requests to a HAR file

You can save requests in the request list as a HAR (HTTP Archive) file and open the file in the developer tools of a web browser or in a HAR viewer.
To export requests:
  1. In the module details pane toolbar, select Export.
  2. Select Save as HAR... or Save as HAR (include sensitive data)....
  3. Choose a name and location for the file.
The saved HAR file contains all requests visible in the list. If you enter text in the search field, the HAR file contains only the requests that match your search term. The Export menu is unavailable when the list is empty.
The two menu items differ in how they treat credentials:
  • Save as HAR... removes the
    Cookie
    ,
    Set-Cookie
    ,
    Authorization
    , and
    Proxy-Authorization
    headers from the file.
  • Save as HAR (include sensitive data)... keeps these headers. Unity asks you to confirm first, because anyone who has the file can use the cookies and authorization headers to act as you.
Neither item removes URLs, query strings, or request and response bodies. These can contain sensitive data such as access tokens or passwords. Review the file before you share it. For more information, refer to Safeguard sensitive data.

Recorded data by request type

How much the module records depends on the API that sends the request. Requests that
UnityWebRequest
sends, including
HttpClient
requests that use
UnityHttpMessageHandler
, go through the Unity transport, which reports most details. For
HttpClient
requests that use any other message handler, the module reads the diagnostics data that .NET publishes, which contains less.

Data

UnityWebRequest

HttpClient
with
UnityHttpMessageHandler

HttpClient
with another message handler

URL, method, status code, and durationYesYesYes. In some cases the query string displays as
*
. For more information, refer to HttpClient requests without UnityHttpMessageHandler.
Payload tab: Query String ParametersYesYesYes, when the module records the full URL.
Headers tab: Request Headers (Configured)YesYesYes, including the headers in
HttpClient.DefaultRequestHeaders
and the content headers.
Headers tab: Request Headers (Wire)Yes¹Yes¹No
Headers tab: Response HeadersYesYesNo
Type column (response content type)YesYesNo
Size column and transferred bytesYes¹Yes¹No. The column displays —.
Payload tab: Request Payload, and Response body tabYes¹Yes¹No
Timing tab phasesYes¹Yes¹No. The tab displays only the total duration.
Recorded in Development buildsYesYesOnly with the CoreCLR scripting backend.
¹ Not all platforms support this data.

HttpClient requests without UnityHttpMessageHandler

With the CoreCLR scripting backend, in the Unity Editor and in Development builds, the module records requests that
HttpClient
sends through its default message handler, or through any message handler other than
UnityHttpMessageHandler
. For the data the module records for these requests, refer to Recorded data by request type. These requests also behave as follows:
  • If other code in your project also listens to
    HttpClient
    activities, for example the OpenTelemetry SDK, or if the request starts while an
    Activity
    is already running, .NET doesn't pass the full URL to the Profiler. In that case, the module displays the query string as
    *
    , for example
    https://example.com/items?*
    .
  • Where the module has no data for these requests, such as response headers, bodies, and timing phases, the Headers, Payload, Response body, and Timing tabs say so and suggest
    UnityHttpMessageHandler
    .
  • The Request Headers (Configured) section lists the headers as your code set them, before .NET sends the request. Headers that .NET adds when it sends the request, such as
    Host
    , aren't included.
  • The Transferred item in the summary bar displays a lower bound when the capture contains these requests, because .NET doesn't report transferred bytes.
  • If
    HttpClient
    follows a redirect, the request list displays one row for each request in the redirect chain.
While the Profiler records, .NET adds a
traceparent
header to every request that
HttpClient
sends through these message handlers. The Profiler doesn't cause .NET to add this header when it isn't recording or when the Web Requests module is inactive.
To record all details of
HttpClient
requests, or to record them with other scripting backends, use
UnityHttpMessageHandler
as the message handler. You set the message handler when you create the
HttpClient
, so this applies only to
HttpClient
instances that your code creates. Requests from packages or other code you can't change keep the level of detail that this section describes.

Request limits

The Profiler tracks up to 1,024 requests in flight at the same time. If your application starts more requests while 1,024 are in flight, the Profiler doesn't record them. The Requests item in the summary bar displays the number of dropped requests.
The request list displays up to 2,048 requests. When a capture contains more requests, the list removes the oldest ones, but the summary bar still includes them in its totals.

Safeguard sensitive data

The Web Requests module records the requests your application sends and the responses it receives. This data can include sensitive information, such as passwords, access tokens, and personal data. Unity stores this data in plain text in the Profiler capture, and anyone who has a copy of a saved capture can read it.
Unity records request data only in the Unity Editor and in Development builds, while the Profiler is recording and the Web Requests module is active. A capture can contain the following data for each request:
  • The full URL, including the query string. Some web services expect API keys or access tokens in the query string.
  • The request headers your code sets, the request headers Unity sends, and the response headers. These can include
    Authorization
    headers and cookies.
  • Up to 16 KB of each text request body and response body. For example, the body of a login request can contain a user name and password, and the body of its response can contain an access token.
The module displays a warning icon next to the
Authorization
,
Proxy-Authorization
,
Cookie
, and
Set-Cookie
headers. The module doesn't detect sensitive data anywhere else, such as in custom headers, query strings, or bodies. A request without a warning icon can still contain sensitive data.
To reduce the risk of exposing sensitive data:
  • Deactivate the Web Requests module when you don't need it, and always before you record a capture to share with others. For more information, refer to Activating Profiler modules.
  • Use test accounts, test credentials, and test servers when you profile your application.
  • Treat any capture you record while the Web Requests module is active as sensitive. Don't attach it to bug reports or post it in public forums unless you know it contains no real credentials or personal data.
  • Exclude the
    ProfilerCaptures
    folder from version control, or change the save location in Profiler Preferences. By default, Unity saves captures to the
    ProfilerCaptures
    folder of your project, so anyone with access to your project can open them.

Additional resources