WebResourceResponse
public
class
WebResourceResponse
extends Object
| java.lang.Object | |
| ↳ | android.webkit.WebResourceResponse |
Encapsulates a resource response. Applications can return an instance of this
class from shouldInterceptRequest(WebView, WebResourceRequest) to provide a custom
response when the WebView requests a particular resource.
Summary
Public constructors | |
|---|---|
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. |
|
Public methods | |
|---|---|
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. |
Inherited methods | |
|---|---|
java.lang.Object
| |
Public constructors
WebResourceResponse
WebResourceResponse (String mimeType, String encoding, InputStream data)
Constructs a resource response with the given MIME type, encoding, and
input stream. Callers must implement
InputStream.read(byte[]) for the input
stream.
| Parameters | |
|---|---|
mimeType |
String: the resource response's MIME type, for example text/html |
encoding |
String: the resource response's encoding |
data |
InputStream: the input stream that provides the resource response's data. Must not be a
StringBufferInputStream.
|
WebResourceResponse
WebResourceResponse (String mimeType, String encoding, int statusCode, String reasonPhrase, Map<String, String> responseHeaders, InputStream data)
Constructs a resource response with the given parameters. Callers must
implement InputStream.read(byte[]) for
the input stream.
| Parameters | |
|---|---|
mimeType |
String: the resource response's MIME type, for example text/html |
encoding |
String: the resource response's encoding |
statusCode |
int: 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 |
String: the phrase describing the status code, for example "OK". Must be non-null
and not empty. |
responseHeaders |
Map: the resource response's headers represented as a mapping of header
name -> header value. |
data |
InputStream: the input stream that provides the resource response's data. Must not be a
StringBufferInputStream.
|
Public methods
getData
InputStream getData ()
Gets the input stream that provides the resource response's data.
| Returns | |
|---|---|
InputStream |
The input stream that provides the resource response's data |
getEncoding
String getEncoding ()
Gets the resource response's encoding.
| Returns | |
|---|---|
String |
The resource response's encoding |
getMimeType
String getMimeType ()
Gets the resource response's MIME type.
| Returns | |
|---|---|
String |
The resource response's MIME type |
getReasonPhrase
String getReasonPhrase ()
Gets the description of the resource response's status code.
| Returns | |
|---|---|
String |
The description of the resource response's status code. |
getResponseHeaders
Map<String, String> getResponseHeaders ()
Gets the headers for the resource response.
| Returns | |
|---|---|
Map<String, String> |
The headers for the resource response. |
getStatusCode
int getStatusCode ()
Gets the resource response's status code.
| Returns | |
|---|---|
int |
The resource response's status code. |
setData
void setData (InputStream data)
Sets the input stream that provides the resource response's data. Callers
must implement InputStream.read(byte[]).
| Parameters | |
|---|---|
data |
InputStream: the input stream that provides the resource response's data. Must not be a
StringBufferInputStream.
|
setEncoding
void setEncoding (String encoding)
Sets the resource response's encoding, for example "UTF-8". This is used to decode the data from the input stream.
| Parameters | |
|---|---|
encoding |
String: The resource response's encoding
|
setMimeType
void setMimeType (String mimeType)
Sets the resource response's MIME type, for example "text/html".
| Parameters | |
|---|---|
mimeType |
String: The resource response's MIME type
|
setResponseHeaders
void setResponseHeaders (Map<String, String> headers)
Sets the headers for the resource response.
| Parameters | |
|---|---|
headers |
Map: Mapping of header name -> header value.
|
setStatusCodeAndReasonPhrase
void setStatusCodeAndReasonPhrase (int statusCode,
String reasonPhrase)
Sets the resource response's status code and reason phrase.
| Parameters | |
|---|---|
statusCode |
int: 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 |
String: the phrase describing the status code, for example "OK". Must be non-null
and not empty.
|
Annotations
Interfaces
Classes
- ClientCertRequest
- ConsoleMessage
- CookieManager
- CookieSyncManager
- DateSorter
- GeolocationPermissions
- HttpAuthHandler
- JsPromptResult
- JsResult
- MimeTypeMap
- PermissionRequest
- RenderProcessGoneDetail
- ServiceWorkerClient
- ServiceWorkerController
- ServiceWorkerWebSettings
- SslErrorHandler
- URLUtil
- WebBackForwardList
- WebChromeClient
- WebChromeClient.FileChooserParams
- WebHistoryItem
- WebIconDatabase
- WebMessage
- WebMessagePort
- WebMessagePort.WebMessageCallback
- WebResourceError
- WebResourceResponse
- WebSettings
- WebStorage
- WebStorage.Origin
- WebView
- WebView.HitTestResult
- WebView.VisualStateCallback
- WebView.WebViewTransport
- WebViewClient
- WebViewDatabase
- WebViewFragment
Enums


