Package net.officefloor.server.http.mock
Class MockHttpServer.MockServerHttpConnectionImpl
java.lang.Object
net.officefloor.server.http.mock.MockHttpServer.MockServerHttpConnectionImpl
- All Implemented Interfaces:
MockHttpRequestCallback,MockServerHttpConnection,ServerHttpConnection
- Enclosing class:
- MockHttpServer
public static class MockHttpServer.MockServerHttpConnectionImpl
extends Object
implements MockServerHttpConnection, MockHttpRequestCallback
MockServerHttpConnection implementation.-
Field Summary
Fields inherited from interface net.officefloor.server.http.ServerHttpConnection
DEFAULT_HTTP_ENTITY_CHARSET, HTTP_CHARSET, URI_CHARSET -
Constructor Summary
Constructors -
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.voidresponse(MockHttpResponse response) Callback with theMockHttpResponse.Sends theHttpResponse.
-
Constructor Details
-
MockServerHttpConnectionImpl
Instantiate.- Parameters:
request-MockHttpRequestBuilder.
-
-
Method Details
-
send
Description copied from interface:MockServerHttpConnectionSends theHttpResponse.- Specified by:
sendin interfaceMockServerHttpConnection- Parameters:
escalation- OptionalEscalation. Should benullfor successful processing.- Returns:
MockHttpResponse.
-
response
Description copied from interface:MockHttpRequestCallbackCallback with theMockHttpResponse.- Specified by:
responsein interfaceMockHttpRequestCallback- Parameters:
response-MockHttpResponse.
-
getRequest
Description copied from interface:ServerHttpConnectionObtains theHttpRequestto be serviced.- Specified by:
getRequestin interfaceServerHttpConnection- Returns:
HttpRequestto be serviced.
-
getResponse
Description copied from interface:ServerHttpConnectionObtains theHttpResponse.- Specified by:
getResponsein interfaceServerHttpConnection- Returns:
HttpResponse.
-
isSecure
public boolean isSecure()Description copied from interface:ServerHttpConnectionIndicates if the connection is over a secure channel (e.g. utilising SSL).- Specified by:
isSecurein interfaceServerHttpConnection- Returns:
trueif connection is over a secure channel.
-
getServerLocation
Description copied from interface:ServerHttpConnectionObtains theHttpServerLocation.- Specified by:
getServerLocationin interfaceServerHttpConnection- Returns:
HttpServerLocation.
-
exportState
Description copied from interface:ServerHttpConnectionExports the state of the current
HttpRequestandHttpResponse.This enables maintaining the state of the
HttpRequest/HttpResponseand later reinstating them (typically after a redirect).- Specified by:
exportStatein interfaceServerHttpConnection- Returns:
- Momento containing the current
HttpRequestandHttpResponsestate. - Throws:
IOException- Should the state not be able to be exported.- See Also:
-
importState
Description copied from interface:ServerHttpConnectionImports and overrides the currentHttpRequestandHttpResponsewith the input momento.- Specified by:
importStatein interfaceServerHttpConnection- 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
Description copied from interface:ServerHttpConnectionObtains 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
ServerHttpConnection.getRequest()should be used, as the intention is for this to contain the appropriate information for servicing theHttpRequest.- Specified by:
getClientRequestin interfaceServerHttpConnection- Returns:
- Actual client
HttpRequest. - See Also:
- the POST/redirect/GET pattern that needs to know whether the client
sent
-