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
Constructors -
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.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.
-
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.
-