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
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceFetch flag definitions for network request options. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDon't send cookies or other user data along with the request.static final intDon't automatically follow redirects.static final intNo special treatment.static final intUse the OHTTP relay for this request.static final intAssociates this download with the current private browsing sessionstatic final intThis flag causes a read error in theWebResponsebody. -
Constructor Summary
ConstructorsConstructorDescriptionGeckoWebExecutor(GeckoRuntime runtime) Create a new GeckoWebExecutor instance. -
Method Summary
Modifier and TypeMethodDescriptionfetch(WebRequest request) Send the givenWebRequest.fetch(WebRequest request, int flags) Send the givenWebRequestwith specified flags.Resolves the specified host name.voidspeculativeConnect(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 theWebResponsebody. Useful for testing.- See Also:
-
FETCH_FLAGS_OHTTP
public static final int FETCH_FLAGS_OHTTPUse the OHTTP relay for this request.- See Also:
-
-
Constructor Details
-
GeckoWebExecutor
Create a new GeckoWebExecutor instance.- Parameters:
runtime- A GeckoRuntime instance
-
-
Method Details
-
fetch
Send the givenWebRequest.- Parameters:
request- AWebRequestinstance- Returns:
- A
GeckoResultwhich will be completed with aWebResponse. If the request fails to complete, theGeckoResultwill be completed exceptionally with aWebRequestError. - Throws:
IllegalArgumentException- if request is null or otherwise unusable.
-
fetch
Send the givenWebRequestwith specified flags.- Parameters:
request- AWebRequestinstanceflags- The specified flags. One or more of theFETCH_*flags.- Returns:
- A
GeckoResultwhich will be completed with aWebResponse. If the request fails to complete, theGeckoResultwill 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
GeckoResultwhich will be fulfilled with aListofInetAddress. In case of failure, theGeckoResultwill 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.
-