Class WebResponse

Object
org.mozilla.geckoview.WebMessage
org.mozilla.geckoview.WebResponse

@AnyThread public class WebResponse extends WebMessage
WebResponse represents an HTTP[S] response. It is normally created by GeckoWebExecutor.fetch(WebRequest).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder offers a convenient way to create WebResponse instances.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    An InputStream containing the response body, if available.
    The server certificate used with this response, if any.
    static final long
    The default read timeout for the body stream.
    final boolean
    Whether or not this response was delivered via a secure connection.
    final boolean
    A boolean indicating whether or not this response is the result of a redirection.
    final boolean
    Specifies that the contents should request to be opened in another Android application.
    final boolean
    Specifies that the app may skip requesting the download in the UI.
    final int
    The HTTP status code for the response, e.g.

    Fields inherited from class org.mozilla.geckoview.WebMessage

    headers, uri
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Construct a new WebResponse from the given builder.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    setReadTimeoutMillis(long millis)
    Sets the maximum amount of time to wait for data in the body read() method.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_READ_TIMEOUT_MS

      public static final long DEFAULT_READ_TIMEOUT_MS
      The default read timeout for the body stream.
      See Also:
    • statusCode

      public final int statusCode
      The HTTP status code for the response, e.g. 200.
    • redirected

      public final boolean redirected
      A boolean indicating whether or not this response is the result of a redirection.
    • isSecure

      public final boolean isSecure
      Whether or not this response was delivered via a secure connection.
    • certificate

      @Nullable public final X509Certificate certificate
      The server certificate used with this response, if any.
    • body

      @Nullable public final InputStream body
      An InputStream containing the response body, if available. Attention: the stream must be closed whenever the app is done with it, even when the body is ignored. Otherwise the connection will not be closed until the stream is garbage collected
    • requestExternalApp

      @Nullable public final boolean requestExternalApp
      Specifies that the contents should request to be opened in another Android application. For example, provide PDF content and set this to true to request that Android opens the PDF in a system PDF viewer (if possible and allowed by the user).
    • skipConfirmation

      @Nullable public final boolean skipConfirmation
      Specifies that the app may skip requesting the download in the UI. A confirmation of the download will still be shown.
  • Constructor Details

    • WebResponse

      protected WebResponse(@NonNull WebResponse.Builder builder)
      Construct a new WebResponse from the given builder.
      Parameters:
      builder - Builder instance containing the response parameters
  • Method Details

    • setReadTimeoutMillis

      public void setReadTimeoutMillis(long millis)
      Sets the maximum amount of time to wait for data in the body read() method. By default, the read timeout is set to DEFAULT_READ_TIMEOUT_MS.

      If 0, there will be no timeout and read() will block indefinitely.

      Parameters:
      millis - The duration in milliseconds for the timeout.