Class FetchImpl

java.lang.Object
io.webfolder.cdp.command.FetchImpl
All Implemented Interfaces:
Fetch

public class FetchImpl
extends java.lang.Object
implements Fetch
  • Constructor Summary

    Constructors 
    Constructor Description
    FetchImpl​(SessionInvocationHandler handler)  
  • Method Summary

    Modifier and Type Method Description
    void continueRequest​(java.lang.String requestId)
    Continues the request, optionally modifying some of its parameters.
    void continueRequest​(java.lang.String requestId, java.lang.String url, java.lang.String method, java.lang.String postData, java.util.List<HeaderEntry> headers)
    Continues the request, optionally modifying some of its parameters.
    void continueWithAuth​(java.lang.String requestId, AuthChallengeResponse authChallengeResponse)
    Continues a request supplying authChallengeResponse following authRequired event.
    void disable()
    Disables the fetch domain.
    void enable()
    Enables issuing of requestPaused events.
    void enable​(java.util.List<RequestPattern> patterns, java.lang.Boolean handleAuthRequests)
    Enables issuing of requestPaused events.
    void failRequest​(java.lang.String requestId, ErrorReason errorReason)
    Causes the request to fail with specified reason.
    void fulfillRequest​(java.lang.String requestId, java.lang.Integer responseCode)
    Provides response to the request.
    void fulfillRequest​(java.lang.String requestId, java.lang.Integer responseCode, java.util.List<HeaderEntry> responseHeaders, java.lang.String binaryResponseHeaders, java.lang.String body, java.lang.String responsePhrase)
    Provides response to the request.
    GetResponseBodyResult getResponseBody​(java.lang.String requestId)
    Causes the body of the response to be received from the server and returned as a single string.
    java.lang.String takeResponseBodyAsStream​(java.lang.String requestId)
    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

    • disable

      public void disable()
      Description copied from interface: Fetch
      Disables the fetch domain.
      Specified by:
      disable in interface Fetch
    • enable

      public void enable​(java.util.List<RequestPattern> patterns, java.lang.Boolean handleAuthRequests)
      Description copied from interface: Fetch
      Enables issuing of requestPaused events. A request will be paused until client calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.
      Specified by:
      enable in interface Fetch
      Parameters:
      patterns - If specified, only requests matching any of these patterns will produce fetchRequested event and will be paused until clients response. If not set, all requests will be affected.
      handleAuthRequests - If true, authRequired events will be issued and requests will be paused expecting a call to continueWithAuth.
    • failRequest

      public void failRequest​(java.lang.String requestId, ErrorReason errorReason)
      Description copied from interface: Fetch
      Causes the request to fail with specified reason.
      Specified by:
      failRequest in interface Fetch
      Parameters:
      requestId - An id the client received in requestPaused event.
      errorReason - Causes the request to fail with the given reason.
    • fulfillRequest

      public void fulfillRequest​(java.lang.String requestId, java.lang.Integer responseCode, java.util.List<HeaderEntry> responseHeaders, java.lang.String binaryResponseHeaders, java.lang.String body, java.lang.String responsePhrase)
      Description copied from interface: Fetch
      Provides response to the request.
      Specified by:
      fulfillRequest in interface Fetch
      Parameters:
      requestId - An id the client received in requestPaused event.
      responseCode - An HTTP response code.
      responseHeaders - Response headers.
      binaryResponseHeaders - Alternative way of specifying response headers as a \0-separated series of name: value pairs. Prefer the above method unless you need to represent some non-UTF8 values that can't be transmitted over the protocol as text.
      body - A response body.
      responsePhrase - A textual representation of responseCode. If absent, a standard phrase matching responseCode is used.
    • continueRequest

      public void continueRequest​(java.lang.String requestId, java.lang.String url, java.lang.String method, java.lang.String postData, java.util.List<HeaderEntry> headers)
      Description copied from interface: Fetch
      Continues the request, optionally modifying some of its parameters.
      Specified by:
      continueRequest in interface Fetch
      Parameters:
      requestId - An id the client received in requestPaused event.
      url - If set, the request url will be modified in a way that's not observable by page.
      method - If set, the request method is overridden.
      postData - If set, overrides the post data in the request.
      headers - If set, overrides the request headrts.
    • continueWithAuth

      public void continueWithAuth​(java.lang.String requestId, AuthChallengeResponse authChallengeResponse)
      Description copied from interface: Fetch
      Continues a request supplying authChallengeResponse following authRequired event.
      Specified by:
      continueWithAuth in interface Fetch
      Parameters:
      requestId - An id the client received in authRequired event.
      authChallengeResponse - Response to with an authChallenge.
    • getResponseBody

      public GetResponseBodyResult getResponseBody​(java.lang.String requestId)
      Description copied from interface: Fetch
      Causes the body of the response to be received from the server and returned as a single string. May only be issued for a request that is paused in the Response stage and is mutually exclusive with takeResponseBodyForInterceptionAsStream. Calling other methods that affect the request or disabling fetch domain before body is received results in an undefined behavior.
      Specified by:
      getResponseBody in interface Fetch
      Parameters:
      requestId - Identifier for the intercepted request to get body for.
      Returns:
      GetResponseBodyResult
    • takeResponseBodyAsStream

      public java.lang.String takeResponseBodyAsStream​(java.lang.String requestId)
      Description copied from interface: Fetch
      Returns a handle to the stream representing the response body. The request must be paused in the HeadersReceived stage. Note that after this command the request can't be continued as is -- client either needs to cancel it or to provide the response body. The stream only supports sequential read, IO.read will fail if the position is specified. This method is mutually exclusive with getResponseBody. Calling other methods that affect the request or disabling fetch domain before body is received results in an undefined behavior.
      Specified by:
      takeResponseBodyAsStream in interface Fetch
    • enable

      public void enable()
      Description copied from interface: Fetch
      Enables issuing of requestPaused events. A request will be paused until client calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.
      Specified by:
      enable in interface Fetch
    • fulfillRequest

      public void fulfillRequest​(java.lang.String requestId, java.lang.Integer responseCode)
      Description copied from interface: Fetch
      Provides response to the request.
      Specified by:
      fulfillRequest in interface Fetch
      Parameters:
      requestId - An id the client received in requestPaused event.
      responseCode - An HTTP response code.
    • continueRequest

      public void continueRequest​(java.lang.String requestId)
      Description copied from interface: Fetch
      Continues the request, optionally modifying some of its parameters.
      Specified by:
      continueRequest in interface Fetch
      Parameters:
      requestId - An id the client received in requestPaused event.