Class RequestImpl
- java.lang.Object
-
- com.microsoft.playwright.impl.LoggingSupport
-
- com.microsoft.playwright.impl.ChannelOwner
-
- com.microsoft.playwright.impl.RequestImpl
-
- All Implemented Interfaces:
Request
public class RequestImpl extends ChannelOwner implements Request
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classRequestImpl.FallbackOverrides
-
Field Summary
Fields Modifier and Type Field Description (package private) booleandidFailOrFinish(package private) java.lang.Stringfailureprivate RequestImpl.FallbackOverridesfallbackOverridesprivate RawHeadersheadersprivate byte[]postDataprivate RawHeadersrawHeadersprivate RequestImplredirectedFromprivate RequestImplredirectedTo(package private) Timingtiming-
Fields inherited from class com.microsoft.playwright.impl.ChannelOwner
connection, guid, initializer, type
-
-
Constructor Summary
Constructors Constructor Description RequestImpl(ChannelOwner parent, java.lang.String type, java.lang.String guid, com.google.gson.JsonObject initializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>allHeaders()An object with all the request HTTP headers associated with this request.(package private) voidapplyFallbackOverrides(RequestImpl.FallbackOverrides overrides)java.lang.Stringfailure()The method returnsnullunless this request has failed, as reported byrequestfailedevent.(package private) RequestImpl.FallbackOverridesfallbackOverridesForResume()(package private) RequestfinalRequest()FrameImplframe()Returns theFramethat initiated this request.private RawHeadersgetRawHeaders()java.util.Map<java.lang.String,java.lang.String>headers()An object with the request HTTP headers.java.util.List<HttpHeader>headersArray()An array with all the request HTTP headers associated with this request.java.lang.StringheaderValue(java.lang.String name)Returns the value of the header matching the name.booleanisNavigationRequest()Whether this request is driving frame's navigation.java.lang.Stringmethod()Request's method (GET, POST, etc.)java.lang.StringpostData()Request's post body, if any.byte[]postDataBuffer()Request's post body in a binary form, if any.RequestredirectedFrom()Request that was redirected by the server to this one, if any.RequestredirectedTo()New request issued by the browser if the server responded with redirect.java.lang.StringresourceType()Contains the request's resource type as it was perceived by the rendering engine.ResponseImplresponse()Returns the matchingResponseobject, ornullif the response was not received due to error.Sizessizes()Returns resource size information for given request.Timingtiming()Returns resource timing information for given request.java.lang.Stringurl()URL of the request.-
Methods inherited from class com.microsoft.playwright.impl.ChannelOwner
adopt, disposeChannelOwner, handleEvent, runUntil, sendMessage, sendMessage, sendMessageAsync, toProtocolRef, withLogging, withWaitLogging
-
Methods inherited from class com.microsoft.playwright.impl.LoggingSupport
logApi, logApiIfEnabled, logWithTimestamp, withLogging
-
-
-
-
Field Detail
-
postData
private final byte[] postData
-
redirectedFrom
private RequestImpl redirectedFrom
-
redirectedTo
private RequestImpl redirectedTo
-
headers
private final RawHeaders headers
-
rawHeaders
private RawHeaders rawHeaders
-
failure
java.lang.String failure
-
timing
Timing timing
-
didFailOrFinish
boolean didFailOrFinish
-
fallbackOverrides
private RequestImpl.FallbackOverrides fallbackOverrides
-
-
Constructor Detail
-
RequestImpl
RequestImpl(ChannelOwner parent, java.lang.String type, java.lang.String guid, com.google.gson.JsonObject initializer)
-
-
Method Detail
-
allHeaders
public java.util.Map<java.lang.String,java.lang.String> 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
public java.lang.String 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
public FrameImpl 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
public java.util.Map<java.lang.String,java.lang.String> 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
public java.util.List<HttpHeader> 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
public java.lang.String headerValue(java.lang.String name)
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.
-
isNavigationRequest
public boolean isNavigationRequest()
Description copied from interface:RequestWhether 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.- Specified by:
isNavigationRequestin interfaceRequest
-
method
public java.lang.String method()
Description copied from interface:RequestRequest's method (GET, POST, etc.)
-
postData
public java.lang.String 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
public Request 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
public Request 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
public java.lang.String 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
public ResponseImpl response()
Description copied from interface:RequestReturns the matchingResponseobject, ornullif the response was not received due to error.
-
sizes
public Sizes sizes()
Description copied from interface:RequestReturns resource size information for given request.
-
timing
public Timing 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
public java.lang.String url()
Description copied from interface:RequestURL of the request.
-
finalRequest
Request finalRequest()
-
getRawHeaders
private RawHeaders getRawHeaders()
-
applyFallbackOverrides
void applyFallbackOverrides(RequestImpl.FallbackOverrides overrides)
-
fallbackOverridesForResume
RequestImpl.FallbackOverrides fallbackOverridesForResume()
-
-