Package com.mastfrog.netty.http.client
Class ResponseHandler<T>
java.lang.Object
com.mastfrog.netty.http.client.ResponseHandler<T>
Processes an HTTP response - can be passed to HttpRequestBuilder.execute().
Altenately, you can listen for individual events on the ResponseFuture.
Override one of the receive() methods to get responses.
Basic types and JSON unmarshalling with Jackson are supported out-of-the-box.
To do anything else, override internalReceive.
In the case of a response code greater than 399, the onErrorResponse will be
called with the raw bytes.
- Author:
- Tim Boudreau
-
Constructor Summary
ConstructorsConstructorDescriptionResponseHandler(Class<T> type) ResponseHandler(Class<T> type, com.fasterxml.jackson.databind.ObjectMapper mapper) ResponseHandler(Class<T> type, NettyContentMarshallers marshallers) -
Method Summary
Modifier and TypeMethodDescriptionvoidawait()booleanprotected voidinternalReceive(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.handler.codec.http.HttpHeaders headers, io.netty.buffer.ByteBuf content) protected voidprotected voidonErrorResponse(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.handler.codec.http.HttpHeaders headers, String content) protected voidonErrorResponse(io.netty.handler.codec.http.HttpResponseStatus status, String content) protected voidonErrorResponse(String content) protected voidreceive(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.handler.codec.http.HttpHeaders headers, T obj) protected voidprotected voidtype()
-
Constructor Details
-
ResponseHandler
-
ResponseHandler
-
ResponseHandler
-
-
Method Details
-
await
- Throws:
InterruptedException
-
await
- Throws:
InterruptedException
-
internalReceive
protected void internalReceive(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.handler.codec.http.HttpHeaders headers, io.netty.buffer.ByteBuf content) -
receive
-
receive
protected void receive(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.handler.codec.http.HttpHeaders headers, T obj) -
receive
-
onErrorResponse
-
onErrorResponse
protected void onErrorResponse(io.netty.handler.codec.http.HttpResponseStatus status, String content) -
onErrorResponse
protected void onErrorResponse(io.netty.handler.codec.http.HttpResponseStatus status, io.netty.handler.codec.http.HttpHeaders headers, String content) -
onError
-
type
-