Package org.mozilla.geckoview
Class WebResponse.Builder
Object
org.mozilla.geckoview.WebMessage.Builder
org.mozilla.geckoview.WebResponse.Builder
- Enclosing class:
- WebResponse
Builder offers a convenient way to create WebResponse instances.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdd a HTTP header.body
(InputStream stream) Sets theInputStream
containing the body of this response.build()
certificate
(X509Certificate certificate) Set a HTTP header.isSecure
(boolean isSecure) redirected
(boolean redirected) Set whether or not this response was the result of a redirect.requestExternalApp
(boolean requestExternalApp) Requests that the content be passed to an external Android application.skipConfirmation
(boolean skipConfirmation) Specifies if a confirmation to begin downloading is necessary or not.statusCode
(int code) Set the HTTP status code, e.g.Set the URI
-
Constructor Details
-
Builder
Constructs a new Builder instance with the specified URI.- Parameters:
uri
- A URI String.
-
-
Method Details
-
uri
Description copied from class:WebMessage.Builder
Set the URI- Overrides:
uri
in classWebMessage.Builder
- Parameters:
uri
- A URI String- Returns:
- This Builder instance.
-
header
Description copied from class:WebMessage.Builder
Set a HTTP header. This may be called multiple times for additional headers. If an existing header of the same name exists, it will be replaced by this value.Please note that the HTTP header keys are case-insensitive. It means you can retrieve "Content-Type" with map.get("content-type"), and value for "Content-Type" will be overwritten by map.put("cONTENt-TYpe", value); The keys are also sorted in natural order.
- Overrides:
header
in classWebMessage.Builder
- Parameters:
key
- The key for the HTTP header, e.g. "content-type".value
- The value for the HTTP header, e.g. "application/json".- Returns:
- This Builder instance.
-
addHeader
Description copied from class:WebMessage.Builder
Add a HTTP header. This may be called multiple times for additional headers. If an existing header of the same name exists, the values will be merged.Please note that the HTTP header keys are case-insensitive. It means you can retrieve "Content-Type" with map.get("content-type"), and value for "Content-Type" will be overwritten by map.put("cONTENt-TYpe", value); The keys are also sorted in natural order.
- Overrides:
addHeader
in classWebMessage.Builder
- Parameters:
key
- The key for the HTTP header, e.g. "content-type".value
- The value for the HTTP header, e.g. "application/json".- Returns:
- This Builder instance.
-
body
Sets theInputStream
containing the body of this response.- Parameters:
stream
- AnInputStream
with the body of the response.- Returns:
- This Builder instance.
-
requestExternalApp
Requests that the content be passed to an external Android application. The default is false. For example, set to true to request that the user have the option to open the content in another Android application.- Parameters:
requestExternalApp
- request that the content be opened in another application.- Returns:
- This Builder instance.
-
skipConfirmation
Specifies if a confirmation to begin downloading is necessary or not. (The confirmation that a download occurred will still be shown.) The default is false, which is to request a download confirmation. Skipping the confirmation is only advisable if the user has already opted to download.- Parameters:
skipConfirmation
- whether to skip or show the confirm download flow- Returns:
- This Builder instance.
-
isSecure
- Parameters:
isSecure
- Whether or not this response is secure.- Returns:
- This Builder instance.
-
certificate
- Parameters:
certificate
- The certificate used.- Returns:
- This Builder instance.
-
statusCode
Set the HTTP status code, e.g. 200.- Parameters:
code
- A int representing the HTTP status code.- Returns:
- This Builder instance.
-
redirected
Set whether or not this response was the result of a redirect.- Parameters:
redirected
- A boolean representing whether or not the request was redirected.- Returns:
- This Builder instance.
-
build
- Returns:
- A
WebResponse
constructed with the values from this Builder instance.
-