Package net.officefloor.server.http
Interface ServerHttpConnection
-
- All Known Subinterfaces:
MockServerHttpConnection
- All Known Implementing Classes:
MockHttpServer.MockServerHttpConnectionImpl
,ProcessAwareServerHttpConnectionManagedObject
public interface ServerHttpConnection
HTTP connection to be handled by theOfficeFloor
.- Author:
- Daniel Sagenschneider
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.charset.Charset
DEFAULT_HTTP_ENTITY_CHARSET
HTTP entity defaultCharset
.static java.nio.charset.Charset
HTTP_CHARSET
HTTPCharset
.static java.nio.charset.Charset
URI_CHARSET
URICharset
.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.io.Serializable
exportState()
Exports the state of the currentHttpRequest
andHttpResponse
.HttpRequest
getClientRequest()
Obtains the actual client sentHttpRequest
for theServerHttpConnection
.HttpRequest
getRequest()
Obtains theHttpRequest
to be serviced.HttpResponse
getResponse()
Obtains theHttpResponse
.HttpServerLocation
getServerLocation()
Obtains theHttpServerLocation
.void
importState(java.io.Serializable momento)
Imports and overrides the currentHttpRequest
andHttpResponse
with the input momento.boolean
isSecure()
Indicates if the connection is over a secure channel (e.g.
-
-
-
Method Detail
-
getRequest
HttpRequest getRequest()
Obtains theHttpRequest
to be serviced.- Returns:
HttpRequest
to 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:
true
if connection is over a secure channel.
-
getServerLocation
HttpServerLocation getServerLocation()
Obtains theHttpServerLocation
.- Returns:
HttpServerLocation
.
-
exportState
java.io.Serializable exportState() throws java.io.IOException
Exports the state of the current
HttpRequest
andHttpResponse
.This enables maintaining the state of the
HttpRequest
/HttpResponse
and later reinstating them (typically after a redirect).- Returns:
- Momento containing the current
HttpRequest
andHttpResponse
state. - 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.IOException
Imports and overrides the currentHttpRequest
andHttpResponse
with 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
HttpRequest
for theServerHttpConnection
.As the
HttpRequest
can 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
HttpMethod
is aPOST
orGET
(regardless of imported state) - checking for the
Authorization
HttpHeader
to ensure it was sent by the client for servicing theHttpRequest
- checking for the JWT token
HttpRequestCookie
to 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
-
-