Package org.simpleframework.http.core
Interface BodyEncoder
-
- All Known Implementing Classes:
ChunkedEncoder
,CloseEncoder
,EmptyEncoder
,FixedLengthEncoder
interface BodyEncoder
TheBodyEncoder
object is used to encode content from the HTTP response. This acts in much the same way as an output stream would. As a requirement of RFC 2616 any HTTP/1.1 compliant server must support a set of transfer types. These are fixed size, chunked encoded, and connection close. A producer implementation is required to implement one of this formats for delivery of the response message.- See Also:
BodyObserver
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
This is used to signal to the producer that all content has been written and the user no longer needs to write.void
encode(byte[] array)
This method is used to encode the provided array of bytes in a HTTP/1.1 compliant format and sent it to the client.void
encode(byte[] array, int off, int size)
This method is used to encode the provided array of bytes in a HTTP/1.1 compliant format and sent it to the client.void
encode(java.nio.ByteBuffer buffer)
This method is used to encode the provided buffer of bytes in a HTTP/1.1 compliant format and sent it to the client.void
encode(java.nio.ByteBuffer buffer, int off, int size)
This method is used to encode the provided buffer of bytes in a HTTP/1.1 compliant format and sent it to the client.void
flush()
This method is used to flush the contents of the buffer to the client.
-
-
-
Method Detail
-
encode
void encode(byte[] array) throws java.io.IOException
This method is used to encode the provided array of bytes in a HTTP/1.1 compliant format and sent it to the client. Once the data has been encoded it is handed to the transport layer within the server, which may choose to buffer the data if the content is too small to send efficiently or if the socket is not write ready.- Parameters:
array
- this is the array of bytes to send to the client- Throws:
java.io.IOException
-
encode
void encode(byte[] array, int off, int size) throws java.io.IOException
This method is used to encode the provided array of bytes in a HTTP/1.1 compliant format and sent it to the client. Once the data has been encoded it is handed to the transport layer within the server, which may choose to buffer the data if the content is too small to send efficiently or if the socket is not write ready.- Parameters:
array
- this is the array of bytes to send to the clientoff
- this is the offset within the array to send fromsize
- this is the number of bytes that are to be sent- Throws:
java.io.IOException
-
encode
void encode(java.nio.ByteBuffer buffer) throws java.io.IOException
This method is used to encode the provided buffer of bytes in a HTTP/1.1 compliant format and sent it to the client. Once the data has been encoded it is handed to the transport layer within the server, which may choose to buffer the data if the content is too small to send efficiently or if the socket is not write ready.- Parameters:
buffer
- this is the buffer of bytes to send to the client- Throws:
java.io.IOException
-
encode
void encode(java.nio.ByteBuffer buffer, int off, int size) throws java.io.IOException
This method is used to encode the provided buffer of bytes in a HTTP/1.1 compliant format and sent it to the client. Once the data has been encoded it is handed to the transport layer within the server, which may choose to buffer the data if the content is too small to send efficiently or if the socket is not write ready.- Parameters:
buffer
- this is the buffer of bytes to send to the clientoff
- this is the offset within the buffer to send fromsize
- this is the number of bytes that are to be sent- Throws:
java.io.IOException
-
flush
void flush() throws java.io.IOException
This method is used to flush the contents of the buffer to the client. This method will block until such time as all of the data has been sent to the client. If at any point there is an error sending the content an exception is thrown.- Throws:
java.io.IOException
-
close
void close() throws java.io.IOException
This is used to signal to the producer that all content has been written and the user no longer needs to write. This will either close the underlying transport or it will notify the monitor that the response has completed and the next request can begin. This ensures the content is flushed to the client.- Throws:
java.io.IOException
-
-