Package ej.hoka.http.encoding
Interface TransferEncoding
-
- All Known Implementing Classes:
ChunkedTransferCodingHandler,IdentityTransferEncoding
public interface TransferEncodingInterface for defining HTTP transfer coding handlers.The HTTP transfer coding handler decodes data from the body of a
HttpRequestand encodes the body of aHttpResponse.Transfer coding is specified in
transfer-encodingHTTP header.Encoding handlers should be registered in the
HttpServerin order to use them.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetId()Returns the supported encoding id.java.io.InputStreamopen(HttpRequest request, java.io.InputStream input)Opens anInputStreamthat can be used to decode message body of the given request.java.io.OutputStreamopen(HttpResponse response, java.io.OutputStream output)Opens anOutputStreamthat can be used to encode the message body of theHttpResponse.
-
-
-
Method Detail
-
getId
java.lang.String getId()
Returns the supported encoding id.- Returns:
- an internal
Stringin lower case format.
-
open
java.io.InputStream open(HttpRequest request, java.io.InputStream input) throws java.io.IOException
Opens anInputStreamthat can be used to decode message body of the given request. The returnedInputStreamMUST conforms to the followings:- The
InputStreamMUST reach the EOF (i.e. read methods returns-1) when the request body has been completely read. - The
InputStream.close()method MUST read any remaining bytes from the message body (if any) and MUST NOT close the underlying stream.
- Parameters:
request- theHttpRequestto be decoded by this transfer coding handler.input- theInputStreamfrom which encoded message body can be read.- Returns:
- the
InputStreamused to decode message body of the given request. - Throws:
java.io.IOException- if any I/O Error occurs.
- The
-
open
java.io.OutputStream open(HttpResponse response, java.io.OutputStream output) throws java.io.IOException
Opens anOutputStreamthat can be used to encode the message body of theHttpResponse.- Parameters:
response- theHttpResponseto be encoded by this transfer coding handler.output- theOutputStreamwhere the encoded message body is written.- Returns:
- the output stream used to encode message body of the given response.
- Throws:
java.io.IOException- if any I/O Error occurs.
-
-