|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.webbitserver.stub.StubHttpResponse
public class StubHttpResponse
Implementation of HttpResponse that is easy to construct manually, and inspect results. Useful for testing.
| Constructor Summary | |
|---|---|
StubHttpResponse()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public StubHttpResponse()
| Method Detail |
|---|
public StubHttpResponse charset(Charset charset)
HttpResponse
charset in interface HttpResponsepublic Charset charset()
HttpResponse
charset in interface HttpResponseHttpResponse.charset(Charset)public StubHttpResponse chunked()
HttpResponseHttpResponse.write(String) should be used to send chunks
chunked in interface HttpResponsepublic StubHttpResponse status(int status)
HttpResponse
status in interface HttpResponsepublic int status()
HttpResponse
status in interface HttpResponseHttpResponse.status(int)
public StubHttpResponse header(String name,
String value)
HttpResponse
header in interface HttpResponse
public StubHttpResponse header(String name,
long value)
HttpResponse
header in interface HttpResponse
public StubHttpResponse header(String name,
Date value)
HttpResponse
header in interface HttpResponsepublic StubHttpResponse cookie(HttpCookie httpCookie)
HttpResponse
cookie in interface HttpResponsehttpCookie - the cookie
public StubHttpResponse cookie(String name,
String value)
public String header(String name)
public boolean containsHeader(String name)
HttpResponse
containsHeader in interface HttpResponsepublic StubHttpResponse content(String content)
HttpResponse
content in interface HttpResponseHttpResponse.charset(Charset),
HttpResponse.content(byte[])public 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 in interface HttpResponsecontent - what to writepublic StubHttpResponse content(byte[] content)
HttpResponse
content in interface HttpResponseHttpResponse.content(String)public StubHttpResponse content(ByteBuffer buffer)
HttpResponse
content in interface 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 in interface 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 in interface HttpResponsepublic boolean ended()
public List<HttpCookie> cookies()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||