Package net.officefloor.server.http
Interface ServerHttpConnection
- All Known Subinterfaces:
MockServerHttpConnection
- All Known Implementing Classes:
MockHttpServer.MockServerHttpConnectionImpl,ProcessAwareServerHttpConnectionManagedObject,SpringServerHttpConnection
public interface ServerHttpConnection
HTTP connection to be handled by the
OfficeFloor.- Author:
- Daniel Sagenschneider
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionExports the state of the currentHttpRequestandHttpResponse.Obtains the actual client sentHttpRequestfor theServerHttpConnection.Obtains theHttpRequestto be serviced.Obtains theHttpResponse.Obtains theHttpServerLocation.voidimportState(Serializable momento) Imports and overrides the currentHttpRequestandHttpResponsewith the input momento.booleanisSecure()Indicates if the connection is over a secure channel (e.g.
-
Field Details
-
Method Details
-
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
Exports 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:
IOException- Should the state not be able to be exported.- See Also:
-
importState
Imports and overrides the currentHttpRequestandHttpResponsewith the input momento.- Parameters:
momento- Momento exported from aServerHttpConnection.- Throws:
IllegalArgumentException- Should the momento be invalid.IOException- Should the state not be able to be imported.- See Also:
-
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:
- the POST/redirect/GET pattern that needs to know whether the client
sent
-