Class RequestImpl
- All Implemented Interfaces:
Request
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean(package private) Stringprivate RequestImpl.FallbackOverridesprivate final RawHeadersprivate final byte[]private RawHeadersprivate RequestImplprivate RequestImpl(package private) TimingFields inherited from class com.microsoft.playwright.impl.ChannelOwner
connection, guid, initializer, type -
Constructor Summary
ConstructorsConstructorDescriptionRequestImpl(ChannelOwner parent, String type, String guid, com.google.gson.JsonObject initializer) -
Method Summary
Modifier and TypeMethodDescriptionAn object with all the request HTTP headers associated with this request.(package private) voidfailure()The method returnsnullunless this request has failed, as reported byrequestfailedevent.(package private) RequestImpl.FallbackOverrides(package private) Requestframe()Returns theFramethat initiated this request.private RawHeadersheaders()An object with the request HTTP headers.An array with all the request HTTP headers associated with this request.headerValue(String name) Returns the value of the header matching the name.booleanWhether this request is driving frame's navigation.method()Request's method (GET, POST, etc.)postData()Request's post body, if any.byte[]Request's post body in a binary form, if any.Request that was redirected by the server to this one, if any.New request issued by the browser if the server responded with redirect.Contains the request's resource type as it was perceived by the rendering engine.response()Returns the matchingResponseobject, ornullif the response was not received due to error.sizes()Returns resource size information for given request.timing()Returns resource timing information for given request.url()URL of the request.Methods inherited from class com.microsoft.playwright.impl.ChannelOwner
adopt, disposeChannelOwner, handleEvent, runUntil, sendMessage, sendMessage, sendMessageAsync, toProtocolRef, withLogging, withWaitLoggingMethods inherited from class com.microsoft.playwright.impl.LoggingSupport
logApi, logApiIfEnabled, logWithTimestamp, withLogging
-
Field Details
-
Constructor Details
-
RequestImpl
RequestImpl(ChannelOwner parent, String type, String guid, com.google.gson.JsonObject initializer)
-
-
Method Details
-
allHeaders
Description copied from interface:RequestAn object with all the request HTTP headers associated with this request. The header names are lower-cased.- Specified by:
allHeadersin interfaceRequest
-
failure
Description copied from interface:RequestThe method returnsnullunless this request has failed, as reported byrequestfailedevent.**Usage**
Example of logging of all the failed requests:
page.onRequestFailed(request -> { System.out.println(request.url() + " " + request.failure()); }); -
frame
Description copied from interface:RequestReturns theFramethat initiated this request.**Usage**
String frameUrl = 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.isNavigationRequest()to check that.
Here is an example that handles all the cases:
- When request originates in the Service Worker. You can use
-
headers
Description copied from interface:RequestAn 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 useRequest.allHeaders()for complete list of headers that includecookieinformation. -
headersArray
Description copied from interface:RequestAn array with all the request HTTP headers associated with this request. UnlikeRequest.allHeaders(), header names are NOT lower-cased. Headers with multiple entries, such asSet-Cookie, appear in the array multiple times.- Specified by:
headersArrayin interfaceRequest
-
headerValue
Description copied from interface:RequestReturns the value of the header matching the name. The name is case insensitive.- Specified by:
headerValuein interfaceRequest- Parameters:
name- Name of the header.
-
method
Description copied from interface:RequestRequest's method (GET, POST, etc.) -
postData
Description copied from interface:RequestRequest's post body, if any. -
postDataBuffer
public byte[] postDataBuffer()Description copied from interface:RequestRequest's post body in a binary form, if any.- Specified by:
postDataBufferin interfaceRequest
-
redirectedFrom
Description copied from interface:RequestRequest that was redirected by the server to this one, if any.When the server responds with a redirect, Playwright creates a new
Requestobject. The two requests are connected byredirectedFrom()andredirectedTo()methods. When multiple server redirects has happened, it is possible to construct the whole redirect chain by repeatedly callingredirectedFrom().**Usage**
For example, if the website
http://example.comredirects tohttps://example.com:Response response = page.navigate("http://example.com"); System.out.println(response.request().redirectedFrom().url()); // "http://example.com"If the website
https://google.comhas no redirects:Response response = page.navigate("https://google.com"); System.out.println(response.request().redirectedFrom()); // null- Specified by:
redirectedFromin interfaceRequest
-
redirectedTo
Description copied from interface:RequestNew request issued by the browser if the server responded with redirect.**Usage**
This method is the opposite of
Request.redirectedFrom():System.out.println(request.redirectedFrom().redirectedTo() == request); // true- Specified by:
redirectedToin interfaceRequest
-
resourceType
Description copied from interface:RequestContains 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.- Specified by:
resourceTypein interfaceRequest
-
response
Description copied from interface:RequestReturns the matchingResponseobject, ornullif the response was not received due to error. -
sizes
Description copied from interface:RequestReturns resource size information for given request. -
timing
Description copied from interface:RequestReturns resource timing information for given request. Most of the timing values become available upon the response,responseEndbecomes available when request finishes. Find more information at Resource Timing API.**Usage**
page.onRequestFinished(request -> { Timing timing = request.timing(); System.out.println(timing.responseEnd - timing.startTime); }); page.navigate("http://example.com"); -
url
Description copied from interface:RequestURL of the request. -
finalRequest
Request finalRequest() -
getRawHeaders
-
applyFallbackOverrides
-
fallbackOverridesForResume
RequestImpl.FallbackOverrides fallbackOverridesForResume()
-