Package org.mozilla.geckoview
Class GeckoWebExecutor
Object
org.mozilla.geckoview.GeckoWebExecutor
GeckoWebExecutor is responsible for fetching a
WebRequest
and delivering a WebResponse
to the caller via fetch(WebRequest)
. Example:
final GeckoWebExecutor executor = new GeckoWebExecutor(); final GeckoResult<WebResponse> result = executor.fetch( new WebRequest.Builder("https://example.org/json") .header("Accept", "application/json") .build()); result.then(response -> { // Do something with response });
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Don't send cookies or other user data along with the request.static final int
Don't automatically follow redirects.static final int
No special treatment.static final int
Associates this download with the current private browsing sessionstatic final int
This flag causes a read error in theWebResponse
body. -
Constructor Summary
ConstructorDescriptionGeckoWebExecutor
(GeckoRuntime runtime) Create a new GeckoWebExecutor instance. -
Method Summary
Modifier and TypeMethodDescriptionfetch
(WebRequest request) Send the givenWebRequest
.fetch
(WebRequest request, int flags) Send the givenWebRequest
with specified flags.Resolves the specified host name.void
speculativeConnect
(String uri) This causes a speculative connection to be made to the host in the specified URI.
-
Field Details
-
FETCH_FLAGS_NONE
public static final int FETCH_FLAGS_NONENo special treatment.- See Also:
-
FETCH_FLAGS_ANONYMOUS
public static final int FETCH_FLAGS_ANONYMOUSDon't send cookies or other user data along with the request.- See Also:
-
FETCH_FLAGS_NO_REDIRECTS
public static final int FETCH_FLAGS_NO_REDIRECTSDon't automatically follow redirects.- See Also:
-
FETCH_FLAGS_PRIVATE
public static final int FETCH_FLAGS_PRIVATEAssociates this download with the current private browsing session- See Also:
-
FETCH_FLAGS_STREAM_FAILURE_TEST
public static final int FETCH_FLAGS_STREAM_FAILURE_TESTThis flag causes a read error in theWebResponse
body. Useful for testing.- See Also:
-
-
Constructor Details
-
GeckoWebExecutor
Create a new GeckoWebExecutor instance.- Parameters:
runtime
- A GeckoRuntime instance
-
-
Method Details
-
fetch
Send the givenWebRequest
.- Parameters:
request
- AWebRequest
instance- Returns:
- A
GeckoResult
which will be completed with aWebResponse
. If the request fails to complete, theGeckoResult
will be completed exceptionally with aWebRequestError
. - Throws:
IllegalArgumentException
- if request is null or otherwise unusable.
-
fetch
Send the givenWebRequest
with specified flags.- Parameters:
request
- AWebRequest
instanceflags
- The specified flags. One or more of theFETCH_*
flags.- Returns:
- A
GeckoResult
which will be completed with aWebResponse
. If the request fails to complete, theGeckoResult
will be completed exceptionally with aWebRequestError
. - Throws:
IllegalArgumentException
- if request is null or otherwise unusable.
-
resolve
Resolves the specified host name.- Parameters:
host
- An Internet host name, e.g. mozilla.org.- Returns:
- A
GeckoResult
which will be fulfilled with aList
ofInetAddress
. In case of failure, theGeckoResult
will be completed exceptionally with aUnknownHostException
.
-
speculativeConnect
This causes a speculative connection to be made to the host in the specified URI. This is useful if an app thinks it may be making a request to that host in the near future. If no request is made, the connection will be cleaned up after an unspecified amount of time.- Parameters:
uri
- A URI String.
-