|
| str | url (self) |
| |
| str | resource_type (self) |
| |
| typing.Optional["Worker"] | service_worker (self) |
| |
| str | method (self) |
| |
| typing.Optional[str] | post_data (self) |
| |
| typing.Optional[typing.Any] | post_data_json (self) |
| |
| typing.Optional[bytes] | post_data_buffer (self) |
| |
| "Frame" | frame (self) |
| |
| typing.Optional["Request"] | redirected_from (self) |
| |
| typing.Optional["Request"] | redirected_to (self) |
| |
| typing.Optional[str] | failure (self) |
| |
| ResourceTiming | timing (self) |
| |
| typing.Dict[str, str] | headers (self) |
| |
| RequestSizes | sizes (self) |
| |
| typing.Optional["Response"] | response (self) |
| |
| bool | is_navigation_request (self) |
| |
| typing.Dict[str, str] | all_headers (self) |
| |
| typing.List[NameValue] | headers_array (self) |
| |
| typing.Optional[str] | header_value (self, str name) |
| |
| None | __init__ (self, Any impl_obj) |
| |
|
str | __str__ (self) |
| |
| None | on (self, Any event, Any f) |
| |
| None | once (self, Any event, Any f) |
| |
| None | remove_listener (self, Any event, Any f) |
| |
|
str | __repr__ (self) |
| |
|
|
Callable[..., None] | _wrap_handler (self, Union[Callable[..., Any], Any] handler) |
| |
|
| _loop |
| |
|
| _impl_obj |
| |
◆ all_headers()
| typing.Dict[str, str] playwright.async_api._generated.Request.all_headers |
( |
|
self | ) |
|
Request.all_headers
An object with all the request HTTP headers associated with this request. The header names are lower-cased.
Returns
-------
Dict[str, str]
◆ failure()
| typing.Optional[str] playwright.async_api._generated.Request.failure |
( |
|
self | ) |
|
Request.failure
The method returns `null` unless this request has failed, as reported by `requestfailed` event.
**Usage**
Example of logging of all the failed requests:
```py
page.on(\"requestfailed\", lambda request: print(request.url + \" \" + request.failure))
```
Returns
-------
Union[str, None]
◆ frame()
| "Frame" playwright.async_api._generated.Request.frame |
( |
|
self | ) |
|
Request.frame
Returns the `Frame` that initiated this request.
**Usage**
```py
frame_url = request.frame.url
```
**Details**
Note that in some cases the frame is not available, and this method will throw.
- When request originates in the Service Worker. You can use `request.serviceWorker()` to check that.
- When navigation request is issued before the corresponding frame is created. You can use
`request.is_navigation_request()` to check that.
Here is an example that handles all the cases:
Returns
-------
Frame
◆ header_value()
| typing.Optional[str] playwright.async_api._generated.Request.header_value |
( |
|
self, |
|
|
str |
name |
|
) |
| |
Request.header_value
Returns the value of the header matching the name. The name is case-insensitive.
Parameters
----------
name : str
Name of the header.
Returns
-------
Union[str, None]
◆ headers()
| typing.Dict[str, str] playwright.async_api._generated.Request.headers |
( |
|
self | ) |
|
Request.headers
An object with the request HTTP headers. The header names are lower-cased. Note that this method does not return
security-related headers, including cookie-related ones. You can use `request.all_headers()` for complete
list of headers that include `cookie` information.
Returns
-------
Dict[str, str]
◆ headers_array()
| typing.List[NameValue] playwright.async_api._generated.Request.headers_array |
( |
|
self | ) |
|
Request.headers_array
An array with all the request HTTP headers associated with this request. Unlike `request.all_headers()`,
header names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple
times.
Returns
-------
List[{name: str, value: str}]
◆ is_navigation_request()
| bool playwright.async_api._generated.Request.is_navigation_request |
( |
|
self | ) |
|
Request.is_navigation_request
Whether this request is driving frame's navigation.
Some navigation requests are issued before the corresponding frame is created, and therefore do not have
`request.frame()` available.
Returns
-------
bool
◆ method()
| str playwright.async_api._generated.Request.method |
( |
|
self | ) |
|
Request.method
Request's method (GET, POST, etc.)
Returns
-------
str
◆ post_data()
| typing.Optional[str] playwright.async_api._generated.Request.post_data |
( |
|
self | ) |
|
Request.post_data
Request's post body, if any.
Returns
-------
Union[str, None]
◆ post_data_buffer()
| typing.Optional[bytes] playwright.async_api._generated.Request.post_data_buffer |
( |
|
self | ) |
|
Request.post_data_buffer
Request's post body in a binary form, if any.
Returns
-------
Union[bytes, None]
◆ post_data_json()
| typing.Optional[typing.Any] playwright.async_api._generated.Request.post_data_json |
( |
|
self | ) |
|
Request.post_data_json
Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.
When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
Otherwise it will be parsed as JSON.
Returns
-------
Union[Any, None]
◆ redirected_from()
| typing.Optional["Request"] playwright.async_api._generated.Request.redirected_from |
( |
|
self | ) |
|
Request.redirected_from
Request that was redirected by the server to this one, if any.
When the server responds with a redirect, Playwright creates a new `Request` object. The two requests are connected
by `redirectedFrom()` and `redirectedTo()` methods. When multiple server redirects has happened, it is possible to
construct the whole redirect chain by repeatedly calling `redirectedFrom()`.
**Usage**
For example, if the website `http://example.com` redirects to `https://example.com`:
```py
response = await page.goto(\"http://example.com\")
print(response.request.redirected_from.url) # \"http://example.com\"
```
If the website `https://google.com` has no redirects:
```py
response = await page.goto(\"https://google.com\")
print(response.request.redirected_from) # None
```
Returns
-------
Union[Request, None]
◆ redirected_to()
| typing.Optional["Request"] playwright.async_api._generated.Request.redirected_to |
( |
|
self | ) |
|
Request.redirected_to
New request issued by the browser if the server responded with redirect.
**Usage**
This method is the opposite of `request.redirected_from()`:
```py
assert request.redirected_from.redirected_to == request
```
Returns
-------
Union[Request, None]
◆ resource_type()
| str playwright.async_api._generated.Request.resource_type |
( |
|
self | ) |
|
Request.resource_type
Contains the request's resource type as it was perceived by the rendering engine. ResourceType will be one of the
following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`,
`eventsource`, `websocket`, `manifest`, `other`.
Returns
-------
str
◆ response()
| typing.Optional["Response"] playwright.async_api._generated.Request.response |
( |
|
self | ) |
|
Request.response
Returns the matching `Response` object, or `null` if the response was not received due to error.
Returns
-------
Union[Response, None]
◆ service_worker()
| typing.Optional["Worker"] playwright.async_api._generated.Request.service_worker |
( |
|
self | ) |
|
Request.service_worker
The Service `Worker` that is performing the request.
**Details**
This method is Chromium only. It's safe to call when using other browsers, but it will always be `null`.
Requests originated in a Service Worker do not have a `request.frame()` available.
Returns
-------
Union[Worker, None]
◆ sizes()
| RequestSizes playwright.async_api._generated.Request.sizes |
( |
|
self | ) |
|
Request.sizes
Returns resource size information for given request.
Returns
-------
{requestBodySize: int, requestHeadersSize: int, responseBodySize: int, responseHeadersSize: int}
◆ timing()
Request.timing
Returns resource timing information for given request. Most of the timing values become available upon the
response, `responseEnd` becomes available when request finishes. Find more information at
[Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
**Usage**
```py
async with page.expect_event(\"requestfinished\") as request_info:
await page.goto(\"http://example.com\")
request = await request_info.value
print(request.timing)
```
Returns
-------
{startTime: float, domainLookupStart: float, domainLookupEnd: float, connectStart: float, secureConnectionStart: float, connectEnd: float, requestStart: float, responseStart: float, responseEnd: float}
◆ url()
| str playwright.async_api._generated.Request.url |
( |
|
self | ) |
|
Request.url
URL of the request.
Returns
-------
str
The documentation for this class was generated from the following file:
- docs/help/help-venv/lib/python3.12/site-packages/playwright/async_api/_generated.py