Class WebRequest

Object
org.mozilla.geckoview.WebMessage
org.mozilla.geckoview.WebRequest

@AnyThread public class WebRequest extends WebMessage
WebRequest represents an HTTP[S] request. The typical pattern is to create instances of this class via WebRequest.Builder, and fetch responses via GeckoWebExecutor.fetch(WebRequest).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder offers a convenient way for constructing WebRequest instances.
    static @interface 
    Cache mode definitions for web requests.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final boolean
    If true, do not use newer protocol features that might have interop problems on the Internet.
    The body of the request.
    static final int
    Default cache mode.
    static final int
    If a response is found in the cache, it will be returned, whether it's fresh or not.
    static final int
    Forces a conditional request to the server if there is a cache match.
    static final int
    The response will be fetched from the server without looking in the cache, and will not update the cache with the downloaded response.
    static final int
    If a response is found in the cache, it will be returned, whether it's fresh or not.
    static final int
    The response will be fetched from the server without looking in the cache.
    final int
    The cache mode for the request.
    final String
    The HTTP method for the request.
    final String
    The value of the Referer header for this request.

    Fields inherited from class org.mozilla.geckoview.WebMessage

    headers, uri
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a WebRequest with the specified URI.
  • Method Summary

    Methods inherited from class java.lang.Object

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

    • method

      @NonNull public final String method
      The HTTP method for the request. Defaults to "GET".
    • body

      @Nullable public final ByteBuffer body
      The body of the request. Must be a directly-allocated ByteBuffer. May be null.
    • cacheMode

      public final int cacheMode
      The cache mode for the request. See CACHE_MODE_DEFAULT. These modes match those from the DOM Fetch API.
      See Also:
    • beConservative

      public final boolean beConservative
      If true, do not use newer protocol features that might have interop problems on the Internet. Intended only for use with critical infrastructure.
    • referrer

      @Nullable public final String referrer
      The value of the Referer header for this request.
    • CACHE_MODE_DEFAULT

      public static final int CACHE_MODE_DEFAULT
      Default cache mode. Normal caching rules apply.
      See Also:
    • CACHE_MODE_NO_STORE

      public static final int CACHE_MODE_NO_STORE
      The response will be fetched from the server without looking in the cache, and will not update the cache with the downloaded response.
      See Also:
    • CACHE_MODE_RELOAD

      public static final int CACHE_MODE_RELOAD
      The response will be fetched from the server without looking in the cache. The cache will be updated with the downloaded response.
      See Also:
    • CACHE_MODE_NO_CACHE

      public static final int CACHE_MODE_NO_CACHE
      Forces a conditional request to the server if there is a cache match.
      See Also:
    • CACHE_MODE_FORCE_CACHE

      public static final int CACHE_MODE_FORCE_CACHE
      If a response is found in the cache, it will be returned, whether it's fresh or not. If there is no match, a normal request will be made and the cache will be updated with the downloaded response.
      See Also:
    • CACHE_MODE_ONLY_IF_CACHED

      public static final int CACHE_MODE_ONLY_IF_CACHED
      If a response is found in the cache, it will be returned, whether it's fresh or not. If there is no match from the cache, 504 Gateway Timeout will be returned.
      See Also:
  • Constructor Details

    • WebRequest

      public WebRequest(@NonNull String uri)
      Constructs a WebRequest with the specified URI.
      Parameters:
      uri - A URI String, e.g. https://mozilla.org