public class StubHttpResponse extends Object implements HttpResponse
| 限定符和类型 | 字段和说明 |
|---|---|
private Charset |
charset |
private ByteArrayOutputStream |
contents |
private List<HttpCookie> |
cookies |
private boolean |
ended |
private Throwable |
error |
private Map<String,String> |
headers |
private int |
status |
| 构造器和说明 |
|---|
StubHttpResponse() |
| 限定符和类型 | 方法和说明 |
|---|---|
Charset |
charset()
Current Charset used to encode to response as.
|
StubHttpResponse |
charset(Charset charset)
For text based responses, sets the Charset to encode the response as.
|
StubHttpResponse |
chunked()
Turns the response into a chunked response
after this method is called,
HttpResponse.write(String) should be used to send chunks |
boolean |
containsHeader(String name)
Test to see if this response has a header of the specified name
|
StubHttpResponse |
content(byte[] content)
Write binary based content back to the client.
|
StubHttpResponse |
content(ByteBuffer buffer)
Write binary based content back to the client.
|
StubHttpResponse |
content(String content)
Write text based content back to the client.
|
byte[] |
contents() |
String |
contentsString() |
StubHttpResponse |
cookie(HttpCookie httpCookie)
Adds a cookie
|
StubHttpResponse |
cookie(String name,
String value) |
List<HttpCookie> |
cookies() |
StubHttpResponse |
end()
Marks the response as ended.
|
boolean |
ended() |
Throwable |
error() |
StubHttpResponse |
error(Throwable error)
Marks the response as erroneous.
|
String |
header(String name) |
StubHttpResponse |
header(String name,
Date value)
Adds a Date (RFC 1123 format) HTTP header.
|
StubHttpResponse |
header(String name,
long value)
Adds a numeric HTTP header.
|
StubHttpResponse |
header(String name,
String value)
Adds an HTTP header.
|
int |
status()
Retrieve HTTP status code that this response is going to return.
|
StubHttpResponse |
status(int status)
Sets the HTTP status code.
|
String |
toString() |
StubHttpResponse |
write(String content)
Writes immediately to the client without closing the connection.
|
private Charset charset
private int status
private Throwable error
private boolean ended
private ByteArrayOutputStream contents
private List<HttpCookie> cookies
public StubHttpResponse charset(Charset charset)
HttpResponsecharset 在接口中 HttpResponsepublic Charset charset()
HttpResponsecharset 在接口中 HttpResponseHttpResponse.charset(java.nio.charset.Charset)public StubHttpResponse chunked()
HttpResponseHttpResponse.write(String) should be used to send chunkschunked 在接口中 HttpResponsepublic StubHttpResponse status(int status)
HttpResponsestatus 在接口中 HttpResponsepublic int status()
HttpResponsestatus 在接口中 HttpResponseHttpResponse.status(int)public StubHttpResponse header(String name, String value)
HttpResponseheader 在接口中 HttpResponsepublic StubHttpResponse header(String name, long value)
HttpResponseheader 在接口中 HttpResponsepublic StubHttpResponse header(String name, Date value)
HttpResponseheader 在接口中 HttpResponsepublic StubHttpResponse cookie(HttpCookie httpCookie)
HttpResponsecookie 在接口中 HttpResponsehttpCookie - the cookiepublic StubHttpResponse cookie(String name, String value)
public boolean containsHeader(String name)
HttpResponsecontainsHeader 在接口中 HttpResponsepublic StubHttpResponse content(String content)
HttpResponsepublic StubHttpResponse write(String content)
HttpResponseHttpResponse.content(String) method caches content until HttpResponse.end() is called()
TODO: Make content write immediately instead and remove this method?write 在接口中 HttpResponsecontent - what to writepublic StubHttpResponse content(byte[] content)
HttpResponsecontent 在接口中 HttpResponseHttpResponse.content(String)public StubHttpResponse content(ByteBuffer buffer)
HttpResponsecontent 在接口中 HttpResponseHttpResponse.content(String)public byte[] contents()
public String contentsString()
public StubHttpResponse error(Throwable error)
HttpResponseHttpResponse.end() or HttpResponse.error(Throwable) called. No more
operations should be performed on a response after these.error 在接口中 HttpResponsepublic Throwable error()
public StubHttpResponse end()
HttpResponseHttpResponse.end() or HttpResponse.error(Throwable) called. No more
operations should be performed on a response after these.end 在接口中 HttpResponsepublic boolean ended()
public List<HttpCookie> cookies()
Copyright © 2014. All rights reserved.