Package io.webfolder.cdp.command
Interface Network
-
public interface Network
Network domain allows tracking network activities of the page It exposes information about http, file, data and other requests and responses, their headers, bodies, timing, etc
-
-
Method Summary
Modifier and Type Method Description java.lang.Boolean
canClearBrowserCache()
Tells whether clearing browser cache is supported.java.lang.Boolean
canClearBrowserCookies()
Tells whether clearing browser cookies is supported.java.lang.Boolean
canEmulateNetworkConditions()
Tells whether emulation of network conditions is supported.void
clearBrowserCache()
Clears browser cache.void
clearBrowserCookies()
Clears browser cookies.void
continueInterceptedRequest(java.lang.String interceptionId)
Response to Network.requestIntercepted which either modifies the request to continue with any modifications, or blocks it, or completes it with the provided response bytes.void
continueInterceptedRequest(java.lang.String interceptionId, ErrorReason errorReason, java.lang.String rawResponse, java.lang.String url, java.lang.String method, java.lang.String postData, java.util.Map<java.lang.String,java.lang.Object> headers, AuthChallengeResponse authChallengeResponse)
Response to Network.requestIntercepted which either modifies the request to continue with any modifications, or blocks it, or completes it with the provided response bytes.void
deleteCookies(java.lang.String name)
Deletes browser cookies with matching name and url or domain/path pair.void
deleteCookies(java.lang.String name, java.lang.String url, java.lang.String domain, java.lang.String path)
Deletes browser cookies with matching name and url or domain/path pair.void
disable()
Disables network tracking, prevents network events from being sent to the client.void
emulateNetworkConditions(java.lang.Boolean offline, java.lang.Double latency, java.lang.Double downloadThroughput, java.lang.Double uploadThroughput)
Activates emulation of network conditions.void
emulateNetworkConditions(java.lang.Boolean offline, java.lang.Double latency, java.lang.Double downloadThroughput, java.lang.Double uploadThroughput, ConnectionType connectionType)
Activates emulation of network conditions.void
enable()
Enables network tracking, network events will now be delivered to the client.void
enable(java.lang.Integer maxTotalBufferSize, java.lang.Integer maxResourceBufferSize, java.lang.Integer maxPostDataSize)
Enables network tracking, network events will now be delivered to the client.java.util.List<Cookie>
getAllCookies()
Returns all browser cookies.java.util.List<java.lang.String>
getCertificate(java.lang.String origin)
Returns the DER-encoded certificate.java.util.List<Cookie>
getCookies()
Returns all browser cookies for the current URL.java.util.List<Cookie>
getCookies(java.util.List<java.lang.String> urls)
Returns all browser cookies for the current URL.byte[]
getRequestPostData(java.lang.String requestId)
Returns post data sent with the request.GetResponseBodyResult
getResponseBody(java.lang.String requestId)
Returns content served for the given request.GetResponseBodyForInterceptionResult
getResponseBodyForInterception(java.lang.String interceptionId)
Returns content served for the given currently intercepted request.void
replayXHR(java.lang.String requestId)
This method sends a new XMLHttpRequest which is identical to the original one.java.util.List<SearchMatch>
searchInResponseBody(java.lang.String requestId, java.lang.String query)
Searches for given string in response content.java.util.List<SearchMatch>
searchInResponseBody(java.lang.String requestId, java.lang.String query, java.lang.Boolean caseSensitive, java.lang.Boolean isRegex)
Searches for given string in response content.void
setBlockedURLs(java.util.List<java.lang.String> urls)
Blocks URLs from loading.void
setBypassServiceWorker(java.lang.Boolean bypass)
Toggles ignoring of service worker for each request.void
setCacheDisabled(java.lang.Boolean cacheDisabled)
Toggles ignoring cache for each request.java.lang.Boolean
setCookie(java.lang.String name, java.lang.String value)
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.java.lang.Boolean
setCookie(java.lang.String name, java.lang.String value, java.lang.String url, java.lang.String domain, java.lang.String path, java.lang.Boolean secure, java.lang.Boolean httpOnly, CookieSameSite sameSite, java.lang.Double expires)
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.void
setCookies(java.util.List<CookieParam> cookies)
Sets given cookies.void
setDataSizeLimitsForTest(java.lang.Integer maxTotalSize, java.lang.Integer maxResourceSize)
For testing.void
setExtraHTTPHeaders(java.util.Map<java.lang.String,java.lang.Object> headers)
Specifies whether to always send extra HTTP headers with the requests from this page.void
setRequestInterception(java.util.List<RequestPattern> patterns)
Sets the requests to intercept that match a the provided patterns and optionally resource types.void
setUserAgentOverride(java.lang.String userAgent)
Allows overriding user agent with the given string.void
setUserAgentOverride(java.lang.String userAgent, java.lang.String acceptLanguage, java.lang.String platform)
Allows overriding user agent with the given string.java.lang.String
takeResponseBodyForInterceptionAsStream(java.lang.String interceptionId)
Returns a handle to the stream representing the response body.
-
-
-
Method Detail
-
canClearBrowserCache
java.lang.Boolean canClearBrowserCache()
Tells whether clearing browser cache is supported.- Returns:
- True if browser cache can be cleared.
-
canClearBrowserCookies
java.lang.Boolean canClearBrowserCookies()
Tells whether clearing browser cookies is supported.- Returns:
- True if browser cookies can be cleared.
-
canEmulateNetworkConditions
java.lang.Boolean canEmulateNetworkConditions()
Tells whether emulation of network conditions is supported.- Returns:
- True if emulation of network conditions is supported.
-
clearBrowserCache
void clearBrowserCache()
Clears browser cache.
-
clearBrowserCookies
void clearBrowserCookies()
Clears browser cookies.
-
continueInterceptedRequest
void continueInterceptedRequest(java.lang.String interceptionId, ErrorReason errorReason, java.lang.String rawResponse, java.lang.String url, java.lang.String method, java.lang.String postData, java.util.Map<java.lang.String,java.lang.Object> headers, AuthChallengeResponse authChallengeResponse)
Response to Network.requestIntercepted which either modifies the request to continue with any modifications, or blocks it, or completes it with the provided response bytes. If a network fetch occurs as a result which encounters a redirect an additional Network.requestIntercepted event will be sent with the same InterceptionId.- Parameters:
errorReason
- If set this causes the request to fail with the given reason. PassingAborted
for requests marked withisNavigationRequest
also cancels the navigation. Must not be set in response to an authChallenge.rawResponse
- If set the requests completes using with the provided base64 encoded raw response, including HTTP status line and headers etc... Must not be set in response to an authChallenge.url
- If set the request url will be modified in a way that's not observable by page. Must not be set in response to an authChallenge.method
- If set this allows the request method to be overridden. Must not be set in response to an authChallenge.postData
- If set this allows postData to be set. Must not be set in response to an authChallenge.headers
- If set this allows the request headers to be changed. Must not be set in response to an authChallenge.authChallengeResponse
- Response to a requestIntercepted with an authChallenge. Must not be set otherwise.
-
deleteCookies
void deleteCookies(java.lang.String name, java.lang.String url, java.lang.String domain, java.lang.String path)
Deletes browser cookies with matching name and url or domain/path pair.- Parameters:
name
- Name of the cookies to remove.url
- If specified, deletes all the cookies with the given name where domain and path match provided URL.domain
- If specified, deletes only cookies with the exact domain.path
- If specified, deletes only cookies with the exact path.
-
disable
void disable()
Disables network tracking, prevents network events from being sent to the client.
-
emulateNetworkConditions
void emulateNetworkConditions(java.lang.Boolean offline, java.lang.Double latency, java.lang.Double downloadThroughput, java.lang.Double uploadThroughput, ConnectionType connectionType)
Activates emulation of network conditions.- Parameters:
offline
- True to emulate internet disconnection.latency
- Minimum latency from request sent to response headers received (ms).downloadThroughput
- Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.uploadThroughput
- Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling.connectionType
- Connection type if known.
-
enable
void enable(java.lang.Integer maxTotalBufferSize, java.lang.Integer maxResourceBufferSize, java.lang.Integer maxPostDataSize)
Enables network tracking, network events will now be delivered to the client.- Parameters:
maxTotalBufferSize
- Buffer size in bytes to use when preserving network payloads (XHRs, etc).maxResourceBufferSize
- Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc).maxPostDataSize
- Longest post body size (in bytes) that would be included in requestWillBeSent notification
-
getAllCookies
java.util.List<Cookie> getAllCookies()
Returns all browser cookies. Depending on the backend support, will return detailed cookie information in thecookies
field.- Returns:
- Array of cookie objects.
-
getCertificate
java.util.List<java.lang.String> getCertificate(java.lang.String origin)
Returns the DER-encoded certificate.- Parameters:
origin
- Origin to get certificate for.
-
getCookies
java.util.List<Cookie> getCookies(java.util.List<java.lang.String> urls)
Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in thecookies
field.- Parameters:
urls
- The list of URLs for which applicable cookies will be fetched- Returns:
- Array of cookie objects.
-
getResponseBody
GetResponseBodyResult getResponseBody(java.lang.String requestId)
Returns content served for the given request.- Parameters:
requestId
- Identifier of the network request to get content for.- Returns:
- GetResponseBodyResult
-
getRequestPostData
byte[] getRequestPostData(java.lang.String requestId)
Returns post data sent with the request. Returns an error when no data was sent with the request.- Parameters:
requestId
- Identifier of the network request to get content for.- Returns:
- Base64-encoded request body.
-
getResponseBodyForInterception
GetResponseBodyForInterceptionResult getResponseBodyForInterception(java.lang.String interceptionId)
Returns content served for the given currently intercepted request.- Parameters:
interceptionId
- Identifier for the intercepted request to get body for.- Returns:
- GetResponseBodyForInterceptionResult
-
takeResponseBodyForInterceptionAsStream
java.lang.String takeResponseBodyForInterceptionAsStream(java.lang.String interceptionId)
Returns a handle to the stream representing the response body. Note that after this command, the intercepted request can't be continued as is -- you either need to cancel it or to provide the response body. The stream only supports sequential read, IO.read will fail if the position is specified.
-
replayXHR
void replayXHR(java.lang.String requestId)
This method sends a new XMLHttpRequest which is identical to the original one. The following parameters should be identical: method, url, async, request body, extra headers, withCredentials attribute, user, password.- Parameters:
requestId
- Identifier of XHR to replay.
-
searchInResponseBody
java.util.List<SearchMatch> searchInResponseBody(java.lang.String requestId, java.lang.String query, java.lang.Boolean caseSensitive, java.lang.Boolean isRegex)
Searches for given string in response content.- Parameters:
requestId
- Identifier of the network response to search.query
- String to search for.caseSensitive
- If true, search is case sensitive.isRegex
- If true, treats string parameter as regex.- Returns:
- List of search matches.
-
setBlockedURLs
void setBlockedURLs(java.util.List<java.lang.String> urls)
Blocks URLs from loading.- Parameters:
urls
- URL patterns to block. Wildcards ('*') are allowed.
-
setBypassServiceWorker
void setBypassServiceWorker(java.lang.Boolean bypass)
Toggles ignoring of service worker for each request.- Parameters:
bypass
- Bypass service worker and load from network.
-
setCacheDisabled
void setCacheDisabled(java.lang.Boolean cacheDisabled)
Toggles ignoring cache for each request. Iftrue
, cache will not be used.- Parameters:
cacheDisabled
- Cache disabled state.
-
setCookie
java.lang.Boolean setCookie(java.lang.String name, java.lang.String value, java.lang.String url, java.lang.String domain, java.lang.String path, java.lang.Boolean secure, java.lang.Boolean httpOnly, CookieSameSite sameSite, java.lang.Double expires)
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.- Parameters:
name
- Cookie name.value
- Cookie value.url
- The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie.domain
- Cookie domain.path
- Cookie path.secure
- True if cookie is secure.httpOnly
- True if cookie is http-only.sameSite
- Cookie SameSite type.expires
- Cookie expiration date, session cookie if not set- Returns:
- True if successfully set cookie.
-
setCookies
void setCookies(java.util.List<CookieParam> cookies)
Sets given cookies.- Parameters:
cookies
- Cookies to be set.
-
setDataSizeLimitsForTest
void setDataSizeLimitsForTest(java.lang.Integer maxTotalSize, java.lang.Integer maxResourceSize)
For testing.- Parameters:
maxTotalSize
- Maximum total buffer size.maxResourceSize
- Maximum per-resource size.
-
setExtraHTTPHeaders
void setExtraHTTPHeaders(java.util.Map<java.lang.String,java.lang.Object> headers)
Specifies whether to always send extra HTTP headers with the requests from this page.- Parameters:
headers
- Map with extra HTTP headers.
-
setRequestInterception
void setRequestInterception(java.util.List<RequestPattern> patterns)
Sets the requests to intercept that match a the provided patterns and optionally resource types.- Parameters:
patterns
- Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
-
setUserAgentOverride
void setUserAgentOverride(java.lang.String userAgent, java.lang.String acceptLanguage, java.lang.String platform)
Allows overriding user agent with the given string.- Parameters:
userAgent
- User agent to use.acceptLanguage
- Browser langugage to emulate.platform
- The platform navigator.platform should return.
-
continueInterceptedRequest
void continueInterceptedRequest(java.lang.String interceptionId)
Response to Network.requestIntercepted which either modifies the request to continue with any modifications, or blocks it, or completes it with the provided response bytes. If a network fetch occurs as a result which encounters a redirect an additional Network.requestIntercepted event will be sent with the same InterceptionId.
-
deleteCookies
void deleteCookies(java.lang.String name)
Deletes browser cookies with matching name and url or domain/path pair.- Parameters:
name
- Name of the cookies to remove.
-
emulateNetworkConditions
void emulateNetworkConditions(java.lang.Boolean offline, java.lang.Double latency, java.lang.Double downloadThroughput, java.lang.Double uploadThroughput)
Activates emulation of network conditions.- Parameters:
offline
- True to emulate internet disconnection.latency
- Minimum latency from request sent to response headers received (ms).downloadThroughput
- Maximal aggregated download throughput (bytes/sec). -1 disables download throttling.uploadThroughput
- Maximal aggregated upload throughput (bytes/sec). -1 disables upload throttling.
-
enable
void enable()
Enables network tracking, network events will now be delivered to the client.
-
getCookies
java.util.List<Cookie> getCookies()
Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in thecookies
field.- Returns:
- Array of cookie objects.
-
searchInResponseBody
java.util.List<SearchMatch> searchInResponseBody(java.lang.String requestId, java.lang.String query)
Searches for given string in response content.- Parameters:
requestId
- Identifier of the network response to search.query
- String to search for.- Returns:
- List of search matches.
-
setCookie
java.lang.Boolean setCookie(java.lang.String name, java.lang.String value)
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.- Parameters:
name
- Cookie name.value
- Cookie value.- Returns:
- True if successfully set cookie.
-
setUserAgentOverride
void setUserAgentOverride(java.lang.String userAgent)
Allows overriding user agent with the given string.- Parameters:
userAgent
- User agent to use.
-
-