public class WebResourceResponse extends Object
WebViewClient.shouldInterceptRequest(android.webkit.WebView, java.lang.String)
to provide a custom
response when the WebView requests a particular resource.Constructor and Description |
---|
WebResourceResponse(boolean immutable,
String mimeType,
String encoding,
int statusCode,
String reasonPhrase,
Map<String,String> responseHeaders,
InputStream data)
The internal version of the constructor that doesn't perform arguments checks.
|
WebResourceResponse(String mimeType,
String encoding,
InputStream data)
Constructs a resource response with the given MIME type, encoding, and
input stream.
|
WebResourceResponse(String mimeType,
String encoding,
int statusCode,
String reasonPhrase,
Map<String,String> responseHeaders,
InputStream data)
Constructs a resource response with the given parameters.
|
Modifier and Type | Method and Description |
---|---|
InputStream |
getData()
Gets the input stream that provides the resource response's data.
|
String |
getEncoding()
Gets the resource response's encoding.
|
String |
getMimeType()
Gets the resource response's MIME type.
|
String |
getReasonPhrase()
Gets the description of the resource response's status code.
|
Map<String,String> |
getResponseHeaders()
Gets the headers for the resource response.
|
int |
getStatusCode()
Gets the resource response's status code.
|
void |
setData(InputStream data)
Sets the input stream that provides the resource response's data.
|
void |
setEncoding(String encoding)
Sets the resource response's encoding, for example "UTF-8".
|
void |
setMimeType(String mimeType)
Sets the resource response's MIME type, for example "text/html".
|
void |
setResponseHeaders(Map<String,String> headers)
Sets the headers for the resource response.
|
void |
setStatusCodeAndReasonPhrase(int statusCode,
String reasonPhrase)
Sets the resource response's status code and reason phrase.
|
public WebResourceResponse(String mimeType, String encoding, InputStream data)
InputStream.read(byte[])
for the input
stream.mimeType
- the resource response's MIME type, for example text/htmlencoding
- the resource response's encodingdata
- the input stream that provides the resource response's data. Must not be a
StringBufferInputStream.public WebResourceResponse(String mimeType, String encoding, int statusCode, String reasonPhrase, Map<String,String> responseHeaders, InputStream data)
InputStream.read(byte[])
for
the input stream.mimeType
- the resource response's MIME type, for example text/htmlencoding
- the resource response's encodingstatusCode
- the status code needs to be in the ranges [100, 299], [400, 599].
Causing a redirect by specifying a 3xx code is not supported.reasonPhrase
- the phrase describing the status code, for example "OK". Must be non-null
and not empty.responseHeaders
- the resource response's headers represented as a mapping of header
name -> header value.data
- the input stream that provides the resource response's data. Must not be a
StringBufferInputStream.public void setMimeType(String mimeType)
mimeType
- The resource response's MIME typepublic String getMimeType()
public void setEncoding(String encoding)
encoding
- The resource response's encodingpublic String getEncoding()
public void setStatusCodeAndReasonPhrase(int statusCode, String reasonPhrase)
statusCode
- the status code needs to be in the ranges [100, 299], [400, 599].
Causing a redirect by specifying a 3xx code is not supported.reasonPhrase
- the phrase describing the status code, for example "OK". Must be non-null
and not empty.public int getStatusCode()
public String getReasonPhrase()
public void setResponseHeaders(Map<String,String> headers)
headers
- Mapping of header name -> header value.public Map<String,String> getResponseHeaders()
public void setData(InputStream data)
InputStream.read(byte[])
.data
- the input stream that provides the resource response's data. Must not be a
StringBufferInputStream.public InputStream getData()