@Immutable @ThreadSafe public class CamelJettyHttpResponse extends Object implements HttpResponse
HttpResponse to use with CamelJettyHttpSpy.
This implementation is immutable and contains immutable fields.
TODO test.
TODO Make character encoding configurable.
| Modifier | Constructor and Description |
|---|---|
protected |
CamelJettyHttpResponse(int statusCode,
String body,
Map<String,List<String>> headers,
long delayMillis)
Create new instance of response.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getBody()
Gets body.
|
long |
getDelayMillis()
Gets delay in milliseconds before sending the response.
|
Map<String,List<String>> |
getHeaders()
Gets headers.
|
int |
getStatusCode()
Gets status code.
|
protected void |
sendInExchange(org.apache.camel.Exchange exchange)
Send this response in Camel exchange.
|
protected CamelJettyHttpResponse(int statusCode,
String body,
Map<String,List<String>> headers,
long delayMillis)
End user is not supposed to call this constructor and instead should call
AbstractRequestExpectationListBuilder.expect(com.github.tashoyan.httpspy.RequestExpectationBuilder).
statusCode - Response status code.body - Response body.headers - Response headers. If null, then headers will be set to
empty map.delayMillis - Delay in milliseconds before sending the response.NullPointerException - header name is null, list of header values
is null, a header value is null.IllegalArgumentException - header name is empty or blank, list of
header values is empty.IllegalArgumentException - delayMillis is negative.public int getStatusCode()
HttpResponsegetStatusCode in interface HttpResponsepublic String getBody()
HttpResponsegetBody in interface HttpResponsepublic Map<String,List<String>> getHeaders()
HttpResponsegetHeaders in interface HttpResponsepublic long getDelayMillis()
HttpResponsegetDelayMillis in interface HttpResponseprotected void sendInExchange(org.apache.camel.Exchange exchange)
throws InterruptedException
This implementation sends response body in platform default encoding.
If the response has multiple headers with the same name, then this method follows RFC 2616, Section 4.2 Message Headers: combine all values into one string of comma-separated values.
exchange - Send the response as Out message within this exchange
object. Out message allows to drop all headers came with In message.NullPointerException - Exchange is null.InterruptedException - Interrupted while waiting the delayCopyright © 2016. All rights reserved.