Package io.webfolder.cdp.command
Interface NetworkAsync
public interface NetworkAsync
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 TypeMethodDescriptionDeprecated.Deprecated.Deprecated.Clears accepted encodings set by setAcceptedEncodingsClears browser cache.Clears browser cookies.continueInterceptedRequest
(String interceptionId) Deprecated.continueInterceptedRequest
(String interceptionId, ErrorReason errorReason, String rawResponse, String url, String method, String postData, Map<String, Object> headers, AuthChallengeResponse authChallengeResponse) Deprecated.deleteCookies
(String name) Deletes browser cookies with matching name and url or domain/path pair.deleteCookies
(String name, String url, String domain, String path) Deletes browser cookies with matching name and url or domain/path pair.disable()
Disables network tracking, prevents network events from being sent to the client.emulateNetworkConditions
(Boolean offline, Double latency, Double downloadThroughput, Double uploadThroughput) Activates emulation of network conditions.emulateNetworkConditions
(Boolean offline, Double latency, Double downloadThroughput, Double uploadThroughput, ConnectionType connectionType) Activates emulation of network conditions.enable()
Enables network tracking, network events will now be delivered to the client.Enables network tracking, network events will now be delivered to the client.enableReportingApi
(Boolean enable) Enables tracking for the Reporting API, events generated by the Reporting API will now be delivered to the client.Returns all browser cookies.getCertificate
(String origin) Returns the DER-encoded certificate.Returns all browser cookies for the current URL.getCookies
(List<String> urls) Returns all browser cookies for the current URL.getRequestPostData
(String requestId) Returns post data sent with the request.getResponseBody
(String requestId) Returns content served for the given request.getResponseBodyForInterception
(String interceptionId) Returns content served for the given currently intercepted request.Returns information about the COEP/COOP isolation status.getSecurityIsolationStatus
(String frameId) Returns information about the COEP/COOP isolation status.loadNetworkResource
(String url, LoadNetworkResourceOptions options) Fetches the resource and returns the content.loadNetworkResource
(String frameId, String url, LoadNetworkResourceOptions options) Fetches the resource and returns the content.This method sends a new XMLHttpRequest which is identical to the original one.searchInResponseBody
(String requestId, String query) Searches for given string in response content.searchInResponseBody
(String requestId, String query, Boolean caseSensitive, Boolean isRegex) Searches for given string in response content.setAcceptedEncodings
(ContentEncoding encodings) Sets a list of content encodings that will be accepted.setAttachDebugStack
(Boolean enabled) Specifies whether to attach a page script stack id in requestssetBlockedURLs
(List<String> urls) Blocks URLs from loading.setBypassServiceWorker
(Boolean bypass) Toggles ignoring of service worker for each request.setCacheDisabled
(Boolean cacheDisabled) Toggles ignoring cache for each request.Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.setCookie
(String name, String value, String url, String domain, String path, Boolean secure, Boolean httpOnly, CookieSameSite sameSite, Double expires, CookiePriority priority, Boolean sameParty, CookieSourceScheme sourceScheme, Integer sourcePort, String partitionKey) Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.setCookies
(List<CookieParam> cookies) Sets given cookies.setExtraHTTPHeaders
(Map<String, Object> headers) Specifies whether to always send extra HTTP headers with the requests from this page.setRequestInterception
(List<RequestPattern> patterns) Deprecated.setUserAgentOverride
(String userAgent) Allows overriding user agent with the given string.setUserAgentOverride
(String userAgent, String acceptLanguage, String platform, UserAgentMetadata userAgentMetadata) Allows overriding user agent with the given string.takeResponseBodyForInterceptionAsStream
(String interceptionId) Returns a handle to the stream representing the response body.
-
Method Details
-
canClearBrowserCache
Deprecated.Tells whether clearing browser cache is supported.- Returns:
- True if browser cache can be cleared.
-
canClearBrowserCookies
Deprecated.Tells whether clearing browser cookies is supported.- Returns:
- True if browser cookies can be cleared.
-
canEmulateNetworkConditions
Deprecated.Tells whether emulation of network conditions is supported.- Returns:
- True if emulation of network conditions is supported.
-
clearAcceptedEncodingsOverride
CompletableFuture<Void> clearAcceptedEncodingsOverride()Clears accepted encodings set by setAcceptedEncodings -
clearBrowserCache
CompletableFuture<Void> clearBrowserCache()Clears browser cache. -
clearBrowserCookies
CompletableFuture<Void> clearBrowserCookies()Clears browser cookies. -
continueInterceptedRequest
Deprecated.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. Deprecated, use Fetch.continueRequest, Fetch.fulfillRequest and Fetch.failRequest instead. -
continueInterceptedRequest
@Deprecated CompletableFuture<Void> continueInterceptedRequest(String interceptionId, ErrorReason errorReason, String rawResponse, String url, String method, String postData, Map<String, Object> headers, AuthChallengeResponse authChallengeResponse) Deprecated.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. Deprecated, use Fetch.continueRequest, Fetch.fulfillRequest and Fetch.failRequest instead.- Parameters:
errorReason
- If set this causes the request to fail with the given reason. Passing Aborted for requests marked with isNavigationRequest 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. (Encoded as a base64 string when passed over JSON)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
Deletes browser cookies with matching name and url or domain/path pair.- Parameters:
name
- Name of the cookies to remove.
-
deleteCookies
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
CompletableFuture<Void> disable()Disables network tracking, prevents network events from being sent to the client. -
emulateNetworkConditions
CompletableFuture<Void> emulateNetworkConditions(Boolean offline, Double latency, Double downloadThroughput, 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.
-
emulateNetworkConditions
CompletableFuture<Void> emulateNetworkConditions(Boolean offline, Double latency, Double downloadThroughput, 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
CompletableFuture<Void> enable()Enables network tracking, network events will now be delivered to the client. -
enable
CompletableFuture<Void> enable(Integer maxTotalBufferSize, Integer maxResourceBufferSize, 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
-
enableReportingApi
Enables tracking for the Reporting API, events generated by the Reporting API will now be delivered to the client. Enabling triggers 'reportingApiReportAdded' for all existing reports.- Parameters:
enable
- Whether to enable or disable events for the Reporting API
-
getAllCookies
CompletableFuture<List<Cookie>> getAllCookies()Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field.- Returns:
- Array of cookie objects.
-
getCertificate
Returns the DER-encoded certificate.- Parameters:
origin
- Origin to get certificate for.
-
getCookies
CompletableFuture<List<Cookie>> getCookies()Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field.- Returns:
- Array of cookie objects.
-
getCookies
Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the cookies field.- Parameters:
urls
- The list of URLs for which applicable cookies will be fetched. If not specified, it's assumed to be set to the list containing the URLs of the page and all of its subframes.- Returns:
- Array of cookie objects.
-
getRequestPostData
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:
- Request body string, omitting files from multipart requests
-
getResponseBody
Returns content served for the given request.- Parameters:
requestId
- Identifier of the network request to get content for.- Returns:
- GetResponseBodyResult
-
getResponseBodyForInterception
CompletableFuture<GetResponseBodyForInterceptionResult> getResponseBodyForInterception(String interceptionId) Returns content served for the given currently intercepted request.- Parameters:
interceptionId
- Identifier for the intercepted request to get body for.- Returns:
- GetResponseBodyForInterceptionResult
-
getSecurityIsolationStatus
CompletableFuture<SecurityIsolationStatus> getSecurityIsolationStatus()Returns information about the COEP/COOP isolation status. -
getSecurityIsolationStatus
Returns information about the COEP/COOP isolation status.- Parameters:
frameId
- If no frameId is provided, the status of the target is provided.
-
loadNetworkResource
CompletableFuture<LoadNetworkResourcePageResult> loadNetworkResource(String url, LoadNetworkResourceOptions options) Fetches the resource and returns the content.- Parameters:
url
- URL of the resource to get content for.options
- Options for the request.
-
loadNetworkResource
CompletableFuture<LoadNetworkResourcePageResult> loadNetworkResource(String frameId, String url, LoadNetworkResourceOptions options) Fetches the resource and returns the content.- Parameters:
frameId
- Frame id to get the resource for. Mandatory for frame targets, and should be omitted for worker targets.url
- URL of the resource to get content for.options
- Options for the request.
-
replayXHR
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
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.
-
searchInResponseBody
CompletableFuture<List<SearchMatch>> searchInResponseBody(String requestId, String query, Boolean caseSensitive, 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.
-
setAcceptedEncodings
Sets a list of content encodings that will be accepted. Empty list means no encoding is accepted.- Parameters:
encodings
- List of accepted content encodings.
-
setAttachDebugStack
Specifies whether to attach a page script stack id in requests- Parameters:
enabled
- Whether to attach a page script stack for debugging purpose.
-
setBlockedURLs
Blocks URLs from loading.- Parameters:
urls
- URL patterns to block. Wildcards ('*') are allowed.
-
setBypassServiceWorker
Toggles ignoring of service worker for each request.- Parameters:
bypass
- Bypass service worker and load from network.
-
setCacheDisabled
Toggles ignoring cache for each request. If true, cache will not be used.- Parameters:
cacheDisabled
- Cache disabled state.
-
setCookie
Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.- Parameters:
name
- Cookie name.value
- Cookie value.- Returns:
- Always set to true. If an error occurs, the response indicates protocol error.
-
setCookie
CompletableFuture<Boolean> setCookie(String name, String value, String url, String domain, String path, Boolean secure, Boolean httpOnly, CookieSameSite sameSite, Double expires, CookiePriority priority, Boolean sameParty, CookieSourceScheme sourceScheme, Integer sourcePort, String partitionKey) 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, path, source port, and source scheme 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 setpriority
- Cookie Priority type.sameParty
- True if cookie is SameParty.sourceScheme
- Cookie source scheme type.sourcePort
- Cookie source port. Valid values are {-1, [1, 65535]}, -1 indicates an unspecified port. An unspecified port value allows protocol clients to emulate legacy cookie scope for the port. This is a temporary ability and it will be removed in the future.partitionKey
- Cookie partition key. The site of the top-level URL the browser was visiting at the start of the request to the endpoint that set the cookie. If not set, the cookie will be set as not partitioned.- Returns:
- Always set to true. If an error occurs, the response indicates protocol error.
-
setCookies
Sets given cookies.- Parameters:
cookies
- Cookies to be set.
-
setExtraHTTPHeaders
Specifies whether to always send extra HTTP headers with the requests from this page.- Parameters:
headers
- Map with extra HTTP headers.
-
setRequestInterception
Deprecated.Sets the requests to intercept that match the provided patterns and optionally resource types. Deprecated, please use Fetch.enable instead.- Parameters:
patterns
- Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
-
setUserAgentOverride
Allows overriding user agent with the given string.- Parameters:
userAgent
- User agent to use.
-
setUserAgentOverride
CompletableFuture<Void> setUserAgentOverride(String userAgent, String acceptLanguage, String platform, UserAgentMetadata userAgentMetadata) 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.userAgentMetadata
- To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
-
takeResponseBodyForInterceptionAsStream
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.
-