Package org.simpleframework.http.core
Interface BodyObserver
-
- All Known Implementing Classes:
ResponseObserver
interface BodyObserver
TheBodyObserver
object is core to how the requests are processed from a pipeline. This observes the progress of the response streams as they are written to the underlying transport which is typically TCP. If at any point there is an error in the delivery of the response the observer is notified. It can then shutdown the connection, as RFC 2616 suggests on errors.If however the response is delivered successfully the monitor is notified of this event. On successful delivery the monitor will hand the
Channel
back to the server kernel so that the next request can be processed. This ensures ordering of the responses matches ordering of the requests.- See Also:
Controller
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close(ByteWriter writer)
This is used to close the underlying transport.void
commit(ByteWriter writer)
This is used to notify the monitor that the HTTP response is committed and that the header can no longer be changed.void
error(ByteWriter writer)
This is used when there is an error sending the response.long
getTime()
This represents the time at which the response was either ready, closed or in error.boolean
isClosed()
This is used to determine if the response has completed or if there has been an error.boolean
isCommitted()
This can be used to determine whether the response has been committed.boolean
isError()
This is used to determine if the response was in error.void
ready(ByteWriter writer)
This is used when the response has been sent correctly and the connection supports persisted HTTP.
-
-
-
Method Detail
-
close
void close(ByteWriter writer)
This is used to close the underlying transport. A closure is typically done when the response is to a HTTP/1.0 client that does not require a keep alive connection. Also, if the container requests an explicit closure this is used when all of the content for the response has been sent.- Parameters:
writer
- this is the writer used to send the response
-
error
void error(ByteWriter writer)
This is used when there is an error sending the response. On error RFC 2616 suggests a connection closure is the best means to handle the condition, and the one clients should be expecting and support. All errors result in closure of the underlying transport and no more requests are processed.- Parameters:
writer
- this is the writer used to send the response
-
ready
void ready(ByteWriter writer)
This is used when the response has been sent correctly and the connection supports persisted HTTP. When ready the channel is handed back in to the server kernel where the next request on the pipeline is read and used to compose the next entity.- Parameters:
writer
- this is the writer used to send the response
-
commit
void commit(ByteWriter writer)
This is used to notify the monitor that the HTTP response is committed and that the header can no longer be changed. It is also used to indicate whether the response can be reset.- Parameters:
writer
- this is the writer used to send the response
-
isCommitted
boolean isCommitted()
This can be used to determine whether the response has been committed. If the response is committed then the header can no longer be manipulated and the response has been partially send to the client.- Returns:
- true if the response headers have been committed
-
isClosed
boolean isClosed()
This is used to determine if the response has completed or if there has been an error. This basically allows the writer of the response to take action on certain I/O events.- Returns:
- this returns true if there was an error or close
-
isError
boolean isError()
This is used to determine if the response was in error. If the response was in error this allows the writer to throw an exception indicating that there was a problem responding.- Returns:
- this returns true if there was a response error
-
getTime
long getTime()
This represents the time at which the response was either ready, closed or in error. Providing a time here is useful as it allows the time taken to generate a response to be determined even if the response is written asynchronously.- Returns:
- the time when the response completed or failed
-
-