public final class URLResponse
extends java.lang.Object
ProtocolHandler.onRequest(URLRequest)
method that allows providing custom response.
Constructor and Description |
---|
URLResponse()
Constructs a new
URLResponse instance with an empty response data and
HttpStatus.OK response status.
|
URLResponse(byte[] data, HttpStatus status)
Constructs a new
URLResponse instance with the given parameters.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getData()
Returns bytes array that represents response data for the current URL response.
返回表示当前URL响应的响应数据的字节数组。 |
HttpHeadersEx |
getHeaders()
Returns HTTP headers for the current response.
返回当前响应的HTTP标头。 |
HttpStatus |
getStatus()
Returns status for the current URL response.
返回当前URL响应的状态。 |
void |
setData(byte[] data)
Sets response data for the current URL response.
设置当前URL响应的响应数据。 |
void |
setStatus(HttpStatus status)
Sets response status for the current URL response.
设置当前URL响应的响应状态。 |
public URLResponse()
URLResponse
instance with an empty response data and
HttpStatus.OK
response status.
public URLResponse(byte[] data, HttpStatus status)
URLResponse
instance with the given parameters.
data
- the response data. Cannot be
null
.
-响应数据。不可能是 。
status
- the response status. Cannot be
null
.
-响应状态。不可能是 。
java.lang.IllegalArgumentException
- when
data
or
status
parameters are
null
.
public byte[] getData()
public void setData(byte[] data)
data
- response data.
-响应数据。
java.lang.IllegalArgumentException
- when
data
parameter is
null
.
public HttpStatus getStatus()
HttpStatus.OK
.
public void setStatus(HttpStatus status)
status
- the status. Cannot be
null
.
-状态。不可能是 。
java.lang.IllegalArgumentException
- when
status
parameter is
null
.
public HttpHeadersEx getHeaders()