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
ByteBuffer
s and decodes them into HttpResponse
s
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
Modifier and TypeClassDescriptionstatic class
The result from encoding a response.Nested classes/interfaces inherited from class org.jdrupes.httpcodec.protocols.http.HttpDecoder
HttpDecoder.BodyMode
Nested 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, SP
Fields inherited from class org.jdrupes.httpcodec.protocols.http.HttpCodec
messageHeader
-
Constructor Summary
-
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.BodyMode
headerReceived
(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 HttpResponse
newMessage
(String startLine) Checks whether the first line of a message is a valid response.protected HttpResponseDecoder.Result.Factory
Returns the result factory for this codec.Methods inherited from class org.jdrupes.httpcodec.protocols.http.HttpDecoder
header, isAwaitingMessage, isClosed, maxHeaderLength, setMaxHeaderLength, setPeerEncoder
Methods inherited from class org.jdrupes.httpcodec.protocols.http.HttpCodec
bodyCharset
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jdrupes.httpcodec.Decoder
header, setPeerEncoder
-
Constructor Details
-
HttpResponseDecoder
public HttpResponseDecoder()
-
-
Method Details
-
resultFactory
Description copied from class:HttpDecoder
Returns the result factory for this codec.- Specified by:
resultFactory
in classHttpDecoder<HttpResponse,
HttpRequest> - Returns:
- the factory
-
decoding
Description copied from interface:Decoder
Returns the type of the messages decoded by this decoder.- Specified by:
decoding
in interfaceDecoder<HttpResponse,
HttpRequest> - Returns:
- the value
-
decode
public HttpResponseDecoder.Result decode(ByteBuffer in, Buffer out, boolean endOfInput) throws ProtocolException Description copied from class:HttpDecoder
Decodes the next chunk of data.- Specified by:
decode
in interfaceDecoder<HttpResponse,
HttpRequest> - Overrides:
decode
in 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:
newMessage
in 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:HttpDecoder
Informs the derived class that the header has been received completely.- Specified by:
headerReceived
in 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:HttpDecoder
Informs 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:
messageComplete
in classHttpDecoder<HttpResponse,
HttpRequest>
-