Class HttpResponseDecoder
java.lang.Object
org.jdrupes.httpcodec.protocols.http.HttpCodec<T>
org.jdrupes.httpcodec.protocols.http.HttpDecoder<HttpResponse,HttpRequest>
org.jdrupes.httpcodec.protocols.http.client.HttpResponseDecoder
- All Implemented Interfaces:
Codec,Decoder<HttpResponse,HttpRequest>
public class HttpResponseDecoder
extends HttpDecoder<HttpResponse,HttpRequest>
implements Decoder<HttpResponse,HttpRequest>
A decoder for HTTP reponses.
It accepts data from a sequence of
ByteBuffers and decodes them into HttpResponses
and their (optional) payload.
Headers
The decoder converts a Retry-After header with a delay value to
a header with a date by adding the span to the time in the Date header.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe result from encoding a response.Nested classes/interfaces inherited from class org.jdrupes.httpcodec.protocols.http.HttpDecoder
HttpDecoder.BodyModeNested classes/interfaces inherited from interface org.jdrupes.httpcodec.Codec
Codec.ProtocolSwitchResult -
Field Summary
Fields inherited from class org.jdrupes.httpcodec.protocols.http.HttpDecoder
HTTP_VERSION, peerEncoder, protocolVersion, SPFields inherited from class org.jdrupes.httpcodec.protocols.http.HttpCodec
messageHeader -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecode(ByteBuffer in, Buffer out, boolean endOfInput) Decodes the next chunk of data.decoding()Returns the type of the messages decoded by this decoder.protected HttpDecoder.BodyModeheaderReceived(HttpResponse message) Informs the derived class that the header has been received completely.protected Decoder.Result<HttpRequest>messageComplete(Decoder.Result<HttpRequest> result) Informs the derived class that a complete message has been received and the given result will be returned.protected HttpResponsenewMessage(String startLine) Checks whether the first line of a message is a valid response.protected HttpResponseDecoder.Result.FactoryReturns the result factory for this codec.Methods inherited from class org.jdrupes.httpcodec.protocols.http.HttpDecoder
header, isAwaitingMessage, isClosed, maxHeaderLength, setMaxHeaderLength, setPeerEncoderMethods inherited from class org.jdrupes.httpcodec.protocols.http.HttpCodec
bodyCharsetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jdrupes.httpcodec.Decoder
header, setPeerEncoder
-
Constructor Details
-
HttpResponseDecoder
public HttpResponseDecoder()
-
-
Method Details
-
resultFactory
Description copied from class:HttpDecoderReturns the result factory for this codec.- Specified by:
resultFactoryin classHttpDecoder<HttpResponse,HttpRequest> - Returns:
- the factory
-
decoding
Description copied from interface:DecoderReturns the type of the messages decoded by this decoder.- Specified by:
decodingin interfaceDecoder<HttpResponse,HttpRequest> - Returns:
- the value
-
decode
public HttpResponseDecoder.Result decode(ByteBuffer in, Buffer out, boolean endOfInput) throws ProtocolException Description copied from class:HttpDecoderDecodes the next chunk of data.- Specified by:
decodein interfaceDecoder<HttpResponse,HttpRequest> - Overrides:
decodein classHttpDecoder<HttpResponse,HttpRequest> - Parameters:
in- holds the data to be decodedout- gets the body data (if any) written to itendOfInput- true if there is no input left beyond the data currently in the in buffer (indicates end of body or no body at all)- Returns:
- the result
- Throws:
ProtocolException- if the message violates the Protocol
-
newMessage
Checks whether the first line of a message is a valid response.If so, create a new response message object with basic information, else throw an exception.
Called by the base class when a first line is received.
- Specified by:
newMessagein classHttpDecoder<HttpResponse,HttpRequest> - Parameters:
startLine- the first line- Returns:
- the new HttpMessage object that is to hold the decoded data
- Throws:
HttpProtocolException- if the line is not a correct request line
-
headerReceived
Description copied from class:HttpDecoderInforms the derived class that the header has been received completely.- Specified by:
headerReceivedin classHttpDecoder<HttpResponse,HttpRequest> - Parameters:
message- the message- Returns:
- indication how the body will be transferred
- Throws:
HttpProtocolException- if the input violates the HTTPProtocolException
-
messageComplete
Description copied from class:HttpDecoderInforms the derived class that a complete message has been received and the given result will be returned.The derived class may take additional actions and even modify the result. The default implementation simply returns the given result.
- Overrides:
messageCompletein classHttpDecoder<HttpResponse,HttpRequest>
-