Class NetworkImpl

java.lang.Object
io.webfolder.cdp.command.NetworkImpl
All Implemented Interfaces:
Network

public class NetworkImpl
extends java.lang.Object
implements Network
  • Constructor Summary

    Constructors 
    Constructor Description
    NetworkImpl​(SessionInvocationHandler handler)  
  • 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.
    java.lang.String 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, CookiePriority priority)
    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 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • canClearBrowserCache

      public java.lang.Boolean canClearBrowserCache()
      Description copied from interface: Network
      Tells whether clearing browser cache is supported.
      Specified by:
      canClearBrowserCache in interface Network
      Returns:
      True if browser cache can be cleared.
    • canClearBrowserCookies

      public java.lang.Boolean canClearBrowserCookies()
      Description copied from interface: Network
      Tells whether clearing browser cookies is supported.
      Specified by:
      canClearBrowserCookies in interface Network
      Returns:
      True if browser cookies can be cleared.
    • canEmulateNetworkConditions

      public java.lang.Boolean canEmulateNetworkConditions()
      Description copied from interface: Network
      Tells whether emulation of network conditions is supported.
      Specified by:
      canEmulateNetworkConditions in interface Network
      Returns:
      True if emulation of network conditions is supported.
    • clearBrowserCache

      public void clearBrowserCache()
      Description copied from interface: Network
      Clears browser cache.
      Specified by:
      clearBrowserCache in interface Network
    • clearBrowserCookies

      public void clearBrowserCookies()
      Description copied from interface: Network
      Clears browser cookies.
      Specified by:
      clearBrowserCookies in interface Network
    • continueInterceptedRequest

      public 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)
      Description copied from interface: Network
      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.
      Specified by:
      continueInterceptedRequest in interface Network
      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.
      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

      public void deleteCookies​(java.lang.String name, java.lang.String url, java.lang.String domain, java.lang.String path)
      Description copied from interface: Network
      Deletes browser cookies with matching name and url or domain/path pair.
      Specified by:
      deleteCookies in interface Network
      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

      public void disable()
      Description copied from interface: Network
      Disables network tracking, prevents network events from being sent to the client.
      Specified by:
      disable in interface Network
    • emulateNetworkConditions

      public void emulateNetworkConditions​(java.lang.Boolean offline, java.lang.Double latency, java.lang.Double downloadThroughput, java.lang.Double uploadThroughput, ConnectionType connectionType)
      Description copied from interface: Network
      Activates emulation of network conditions.
      Specified by:
      emulateNetworkConditions in interface Network
      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

      public void enable​(java.lang.Integer maxTotalBufferSize, java.lang.Integer maxResourceBufferSize, java.lang.Integer maxPostDataSize)
      Description copied from interface: Network
      Enables network tracking, network events will now be delivered to the client.
      Specified by:
      enable in interface Network
      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

      public java.util.List<Cookie> getAllCookies()
      Description copied from interface: Network
      Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the `cookies` field.
      Specified by:
      getAllCookies in interface Network
      Returns:
      Array of cookie objects.
    • getCertificate

      public java.util.List<java.lang.String> getCertificate​(java.lang.String origin)
      Description copied from interface: Network
      Returns the DER-encoded certificate.
      Specified by:
      getCertificate in interface Network
      Parameters:
      origin - Origin to get certificate for.
    • getCookies

      public java.util.List<Cookie> getCookies​(java.util.List<java.lang.String> urls)
      Description copied from interface: Network
      Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the `cookies` field.
      Specified by:
      getCookies in interface Network
      Parameters:
      urls - The list of URLs for which applicable cookies will be fetched
      Returns:
      Array of cookie objects.
    • getResponseBody

      public GetResponseBodyResult getResponseBody​(java.lang.String requestId)
      Description copied from interface: Network
      Returns content served for the given request.
      Specified by:
      getResponseBody in interface Network
      Parameters:
      requestId - Identifier of the network request to get content for.
      Returns:
      GetResponseBodyResult
    • getRequestPostData

      public java.lang.String getRequestPostData​(java.lang.String requestId)
      Description copied from interface: Network
      Returns post data sent with the request. Returns an error when no data was sent with the request.
      Specified by:
      getRequestPostData in interface Network
      Parameters:
      requestId - Identifier of the network request to get content for.
      Returns:
      Request body string, omitting files from multipart requests
    • getResponseBodyForInterception

      public GetResponseBodyForInterceptionResult getResponseBodyForInterception​(java.lang.String interceptionId)
      Description copied from interface: Network
      Returns content served for the given currently intercepted request.
      Specified by:
      getResponseBodyForInterception in interface Network
      Parameters:
      interceptionId - Identifier for the intercepted request to get body for.
      Returns:
      GetResponseBodyForInterceptionResult
    • takeResponseBodyForInterceptionAsStream

      public java.lang.String takeResponseBodyForInterceptionAsStream​(java.lang.String interceptionId)
      Description copied from interface: Network
      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.
      Specified by:
      takeResponseBodyForInterceptionAsStream in interface Network
    • replayXHR

      public void replayXHR​(java.lang.String requestId)
      Description copied from interface: Network
      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.
      Specified by:
      replayXHR in interface Network
      Parameters:
      requestId - Identifier of XHR to replay.
    • searchInResponseBody

      public java.util.List<SearchMatch> searchInResponseBody​(java.lang.String requestId, java.lang.String query, java.lang.Boolean caseSensitive, java.lang.Boolean isRegex)
      Description copied from interface: Network
      Searches for given string in response content.
      Specified by:
      searchInResponseBody in interface Network
      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

      public void setBlockedURLs​(java.util.List<java.lang.String> urls)
      Description copied from interface: Network
      Blocks URLs from loading.
      Specified by:
      setBlockedURLs in interface Network
      Parameters:
      urls - URL patterns to block. Wildcards ('*') are allowed.
    • setBypassServiceWorker

      public void setBypassServiceWorker​(java.lang.Boolean bypass)
      Description copied from interface: Network
      Toggles ignoring of service worker for each request.
      Specified by:
      setBypassServiceWorker in interface Network
      Parameters:
      bypass - Bypass service worker and load from network.
    • setCacheDisabled

      public void setCacheDisabled​(java.lang.Boolean cacheDisabled)
      Description copied from interface: Network
      Toggles ignoring cache for each request. If `true`, cache will not be used.
      Specified by:
      setCacheDisabled in interface Network
      Parameters:
      cacheDisabled - Cache disabled state.
    • setCookie

      public 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, CookiePriority priority)
      Description copied from interface: Network
      Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
      Specified by:
      setCookie in interface Network
      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
      priority - Cookie Priority type.
      Returns:
      True if successfully set cookie.
    • setCookies

      public void setCookies​(java.util.List<CookieParam> cookies)
      Description copied from interface: Network
      Sets given cookies.
      Specified by:
      setCookies in interface Network
      Parameters:
      cookies - Cookies to be set.
    • setDataSizeLimitsForTest

      public void setDataSizeLimitsForTest​(java.lang.Integer maxTotalSize, java.lang.Integer maxResourceSize)
      Description copied from interface: Network
      For testing.
      Specified by:
      setDataSizeLimitsForTest in interface Network
      Parameters:
      maxTotalSize - Maximum total buffer size.
      maxResourceSize - Maximum per-resource size.
    • setExtraHTTPHeaders

      public void setExtraHTTPHeaders​(java.util.Map<java.lang.String,​java.lang.Object> headers)
      Description copied from interface: Network
      Specifies whether to always send extra HTTP headers with the requests from this page.
      Specified by:
      setExtraHTTPHeaders in interface Network
      Parameters:
      headers - Map with extra HTTP headers.
    • setRequestInterception

      public void setRequestInterception​(java.util.List<RequestPattern> patterns)
      Description copied from interface: Network
      Sets the requests to intercept that match the provided patterns and optionally resource types. Deprecated, please use Fetch.enable instead.
      Specified by:
      setRequestInterception in interface Network
      Parameters:
      patterns - Requests matching any of these patterns will be forwarded and wait for the corresponding continueInterceptedRequest call.
    • setUserAgentOverride

      public void setUserAgentOverride​(java.lang.String userAgent, java.lang.String acceptLanguage, java.lang.String platform)
      Description copied from interface: Network
      Allows overriding user agent with the given string.
      Specified by:
      setUserAgentOverride in interface Network
      Parameters:
      userAgent - User agent to use.
      acceptLanguage - Browser langugage to emulate.
      platform - The platform navigator.platform should return.
    • continueInterceptedRequest

      public void continueInterceptedRequest​(java.lang.String interceptionId)
      Description copied from interface: Network
      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.
      Specified by:
      continueInterceptedRequest in interface Network
    • deleteCookies

      public void deleteCookies​(java.lang.String name)
      Description copied from interface: Network
      Deletes browser cookies with matching name and url or domain/path pair.
      Specified by:
      deleteCookies in interface Network
      Parameters:
      name - Name of the cookies to remove.
    • emulateNetworkConditions

      public void emulateNetworkConditions​(java.lang.Boolean offline, java.lang.Double latency, java.lang.Double downloadThroughput, java.lang.Double uploadThroughput)
      Description copied from interface: Network
      Activates emulation of network conditions.
      Specified by:
      emulateNetworkConditions in interface Network
      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

      public void enable()
      Description copied from interface: Network
      Enables network tracking, network events will now be delivered to the client.
      Specified by:
      enable in interface Network
    • getCookies

      public java.util.List<Cookie> getCookies()
      Description copied from interface: Network
      Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the `cookies` field.
      Specified by:
      getCookies in interface Network
      Returns:
      Array of cookie objects.
    • searchInResponseBody

      public java.util.List<SearchMatch> searchInResponseBody​(java.lang.String requestId, java.lang.String query)
      Description copied from interface: Network
      Searches for given string in response content.
      Specified by:
      searchInResponseBody in interface Network
      Parameters:
      requestId - Identifier of the network response to search.
      query - String to search for.
      Returns:
      List of search matches.
    • setCookie

      public java.lang.Boolean setCookie​(java.lang.String name, java.lang.String value)
      Description copied from interface: Network
      Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
      Specified by:
      setCookie in interface Network
      Parameters:
      name - Cookie name.
      value - Cookie value.
      Returns:
      True if successfully set cookie.
    • setUserAgentOverride

      public void setUserAgentOverride​(java.lang.String userAgent)
      Description copied from interface: Network
      Allows overriding user agent with the given string.
      Specified by:
      setUserAgentOverride in interface Network
      Parameters:
      userAgent - User agent to use.