Package net.officefloor.server.http
Interface ServerHttpConnection
-
- All Known Subinterfaces:
MockServerHttpConnection
- All Known Implementing Classes:
MockHttpServer.MockServerHttpConnectionImpl,ProcessAwareServerHttpConnectionManagedObject
public interface ServerHttpConnectionHTTP connection to be handled by theOfficeFloor.- Author:
- Daniel Sagenschneider
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.charset.CharsetDEFAULT_HTTP_ENTITY_CHARSETHTTP entity defaultCharset.static java.nio.charset.CharsetHTTP_CHARSETHTTPCharset.static java.nio.charset.CharsetURI_CHARSETURICharset.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.io.SerializableexportState()Exports the state of the currentHttpRequestandHttpResponse.HttpRequestgetClientRequest()Obtains the actual client sentHttpRequestfor theServerHttpConnection.HttpRequestgetRequest()Obtains theHttpRequestto be serviced.HttpResponsegetResponse()Obtains theHttpResponse.HttpServerLocationgetServerLocation()Obtains theHttpServerLocation.voidimportState(java.io.Serializable momento)Imports and overrides the currentHttpRequestandHttpResponsewith the input momento.booleanisSecure()Indicates if the connection is over a secure channel (e.g.
-
-
-
Method Detail
-
getRequest
HttpRequest getRequest()
Obtains theHttpRequestto be serviced.- Returns:
HttpRequestto be serviced.
-
getResponse
HttpResponse getResponse()
Obtains theHttpResponse.- Returns:
HttpResponse.
-
isSecure
boolean isSecure()
Indicates if the connection is over a secure channel (e.g. utilising SSL).- Returns:
trueif connection is over a secure channel.
-
getServerLocation
HttpServerLocation getServerLocation()
Obtains theHttpServerLocation.- Returns:
HttpServerLocation.
-
exportState
java.io.Serializable exportState() throws java.io.IOExceptionExports the state of the current
HttpRequestandHttpResponse.This enables maintaining the state of the
HttpRequest/HttpResponseand later reinstating them (typically after a redirect).- Returns:
- Momento containing the current
HttpRequestandHttpResponsestate. - Throws:
java.io.IOException- Should the state not be able to be exported.- See Also:
importState(Serializable)
-
importState
void importState(java.io.Serializable momento) throws java.lang.IllegalArgumentException, java.io.IOExceptionImports and overrides the currentHttpRequestandHttpResponsewith the input momento.- Parameters:
momento- Momento exported from aServerHttpConnection.- Throws:
java.lang.IllegalArgumentException- Should the momento be invalid.java.io.IOException- Should the state not be able to be imported.- See Also:
exportState()
-
getClientRequest
HttpRequest getClientRequest()
Obtains the actual client sent
HttpRequestfor theServerHttpConnection.As the
HttpRequestcan be overridden, this allows logic requiring to know details of the actual clientHttpRequest. Examples of this logic are:- the POST/redirect/GET pattern that needs to know whether the client
sent
HttpMethodis aPOSTorGET(regardless of imported state) - checking for the
AuthorizationHttpHeaderto ensure it was sent by the client for servicing theHttpRequest - checking for the JWT token
HttpRequestCookieto ensure it was sent by the client for servicing theHttpRequest
Note for most application logic the
getRequest()should be used, as the intention is for this to contain the appropriate information for servicing theHttpRequest.- Returns:
- Actual client
HttpRequest. - See Also:
exportState(),importState(Serializable)
- the POST/redirect/GET pattern that needs to know whether the client
sent
-
-