Package io.milton.http.http11
Class DefaultHttp11ResponseHandler
java.lang.Object
io.milton.http.http11.DefaultHttp11ResponseHandler
- All Implemented Interfaces:
Bufferable,ETagGenerator,Http11ResponseHandler
public class DefaultHttp11ResponseHandler
extends Object
implements Http11ResponseHandler, Bufferable
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDefaultHttp11ResponseHandler(AuthenticationService authenticationService, ETagGenerator eTagGenerator, ContentGenerator contentGenerator) -
Method Summary
Modifier and TypeMethodDescriptionETag's serve to identify a particular version of a particular resource.Defaults to io.milton.http.http11.DefaultCacheControlHelperintMaximum size of data to hold in memory per request when buffering output data.voidinitiateExternalAuth(Resource resource, Request request, Response response) voidrespondBadRequest(Resource resource, Response response, Request request) Respond with a 400 statusvoidrespondConflict(Resource resource, Response response, Request request, String message) voidvoidrespondCreated(Resource resource, Response response, Request request) voidrespondDeleteFailed(Request request, Response response, Resource resource, Response.Status status) Called when a delete has failed, including the failure status.voidrespondExpectationFailed(Response response, Request request) Response with a 417voidrespondForbidden(Resource resource, Response response, Request request) Respond with a 403 status - forbiddenvoidrespondHead(Resource resource, Response response, Request request) Generate a HEAD responsevoidrespondMethodNotAllowed(Resource res, Response response, Request request) voidrespondMethodNotImplemented(Resource resource, Response response, Request request) voidrespondNoContent(Resource resource, Response response, Request request) Invoked when an operation is successful, but there is no content, and there is nothing more specific to return (E.g. created) For example, as a result of a PUT when a resouce has been updated)voidrespondNotFound(Response response, Request request) voidrespondNotModified(GetableResource resource, Response response, Request request) voidrespondPartialContent(GetableResource resource, Response response, Request request, Map<String, String> params, Range range) Respond with content from a single range, in a partial GETvoidrespondPartialContent(GetableResource resource, Response response, Request request, Map<String, String> params, List<Range> ranges) Send a partial content response with multiple rangesvoidrespondPreconditionFailed(Request request, Response response, Resource resource) Generate a 412 response,voidrespondRedirect(Response response, Request request, String redirectUrl) voidrespondServerError(Request request, Response response, String reason) Usually a 500 error.voidrespondUnauthorised(Resource resource, Response response, Request request) voidrespondWithOptions(Resource resource, Response response, Request request, List<String> methodsAllowed) voidvoidsetCacheControlHelper(CacheControlHelper cacheControlHelper) voidsetMaxMemorySize(int maxMemorySize) static voidsetModifiedDate(Response response, Resource resource, Auth auth) The modified date response header is used by the client for content caching.voidsetMultipartBoundary(String multipartBoundary) protected voidsetRespondCommonHeaders(Response response, Resource resource, Response.Status status, Auth auth) protected voidsetRespondContentCommonHeaders(Response response, Resource resource, Auth auth) protected voidsetRespondContentCommonHeaders(Response response, Resource resource, Response.Status status, Auth auth)
-
Constructor Details
-
DefaultHttp11ResponseHandler
public DefaultHttp11ResponseHandler(AuthenticationService authenticationService, ETagGenerator eTagGenerator, ContentGenerator contentGenerator)
-
-
Method Details
-
getCacheControlHelper
Defaults to io.milton.http.http11.DefaultCacheControlHelper- Returns:
-
setCacheControlHelper
-
generateEtag
Description copied from interface:ETagGeneratorETag's serve to identify a particular version of a particular resource. If the resource changes, or is replaced, then this value should change- Specified by:
generateEtagin interfaceETagGenerator- Parameters:
r- - the resource to generate the ETag for- Returns:
- - an ETag which uniquely identifies this version of this resource
-
respondWithOptions
public void respondWithOptions(Resource resource, Response response, Request request, List<String> methodsAllowed) - Specified by:
respondWithOptionsin interfaceHttp11ResponseHandler
-
respondNotFound
- Specified by:
respondNotFoundin interfaceHttp11ResponseHandler
-
respondUnauthorised
- Specified by:
respondUnauthorisedin interfaceHttp11ResponseHandler
-
respondMethodNotImplemented
- Specified by:
respondMethodNotImplementedin interfaceHttp11ResponseHandler
-
respondMethodNotAllowed
- Specified by:
respondMethodNotAllowedin interfaceHttp11ResponseHandler
-
respondConflict
- Specified by:
respondConflictin interfaceHttp11ResponseHandler- Parameters:
resource-response-request-message- - optional message to output in the body content
-
respondServerError
Description copied from interface:Http11ResponseHandlerUsually a 500 error. Some error occured processing the request. Note that you might not be able to assume that this will generate all 500 errors since a runtime exception might result in code outside of milton's control generating the 500 response.- Specified by:
respondServerErrorin interfaceHttp11ResponseHandler
-
respondRedirect
- Specified by:
respondRedirectin interfaceHttp11ResponseHandler
-
respondExpectationFailed
Description copied from interface:Http11ResponseHandlerResponse with a 417- Specified by:
respondExpectationFailedin interfaceHttp11ResponseHandler
-
respondCreated
- Specified by:
respondCreatedin interfaceHttp11ResponseHandler
-
respondNoContent
Description copied from interface:Http11ResponseHandlerInvoked when an operation is successful, but there is no content, and there is nothing more specific to return (E.g. created) For example, as a result of a PUT when a resouce has been updated)- Specified by:
respondNoContentin interfaceHttp11ResponseHandler
-
respondPartialContent
public void respondPartialContent(GetableResource resource, Response response, Request request, Map<String, String> params, Range range) throws NotAuthorizedException, BadRequestException, NotFoundExceptionDescription copied from interface:Http11ResponseHandlerRespond with content from a single range, in a partial GET- Specified by:
respondPartialContentin interfaceHttp11ResponseHandler- Throws:
NotAuthorizedExceptionBadRequestExceptionNotFoundException
-
respondPartialContent
public void respondPartialContent(GetableResource resource, Response response, Request request, Map<String, String> params, List<Range> ranges) throws NotAuthorizedException, BadRequestException, NotFoundExceptionSend a partial content response with multiple ranges- Specified by:
respondPartialContentin interfaceHttp11ResponseHandler- Parameters:
resource-response-request-params-ranges-- Throws:
NotAuthorizedExceptionBadRequestExceptionNotFoundException
-
respondHead
Description copied from interface:Http11ResponseHandlerGenerate a HEAD response- Specified by:
respondHeadin interfaceHttp11ResponseHandler
-
respondContent
public void respondContent(Resource resource, Response response, Request request, Map<String, String> params) throws NotAuthorizedException, BadRequestException, NotFoundException- Specified by:
respondContentin interfaceHttp11ResponseHandler- Throws:
NotAuthorizedExceptionBadRequestExceptionNotFoundException
-
respondNotModified
- Specified by:
respondNotModifiedin interfaceHttp11ResponseHandler
-
setRespondContentCommonHeaders
-
setRespondContentCommonHeaders
protected void setRespondContentCommonHeaders(Response response, Resource resource, Response.Status status, Auth auth) -
setRespondCommonHeaders
protected void setRespondCommonHeaders(Response response, Resource resource, Response.Status status, Auth auth) -
setModifiedDate
The modified date response header is used by the client for content caching. It seems obvious that if we have a modified date on the resource we should set it. BUT, because of the interaction with max-age we should always set it to the current date if we have max-age The problem, is that if we find that a condition GET has an expired mod-date (based on maxAge) then we want to respond with content (even if our mod-date hasnt changed. But if we use the actual mod-date in that case, then the browser will continue to use the old mod-date, so will forever more respond with content. So we send a mod-date of now to ensure that future requests will be given a 304 not modified.*- Parameters:
response-resource-auth-
-
respondBadRequest
Description copied from interface:Http11ResponseHandlerRespond with a 400 status- Specified by:
respondBadRequestin interfaceHttp11ResponseHandler
-
respondForbidden
Description copied from interface:Http11ResponseHandlerRespond with a 403 status - forbidden- Specified by:
respondForbiddenin interfaceHttp11ResponseHandler
-
respondDeleteFailed
public void respondDeleteFailed(Request request, Response response, Resource resource, Response.Status status) Description copied from interface:Http11ResponseHandlerCalled when a delete has failed, including the failure status. Note that webdav implementations will respond with a multisttus, while http 1.1 implementations will simply set the response status- Specified by:
respondDeleteFailedin interfaceHttp11ResponseHandlerresource- - the resource which could not be deletedstatus- - the status which has caused the delete to fail.
-
respondPreconditionFailed
Description copied from interface:Http11ResponseHandlerGenerate a 412 response,- Specified by:
respondPreconditionFailedin interfaceHttp11ResponseHandler
-
getAuthenticationService
-
getMaxMemorySize
public int getMaxMemorySize()Maximum size of data to hold in memory per request when buffering output data.- Returns:
-
setMaxMemorySize
public void setMaxMemorySize(int maxMemorySize) -
getBuffering
- Specified by:
getBufferingin interfaceBufferable
-
setBuffering
- Specified by:
setBufferingin interfaceBufferable
-
initiateExternalAuth
-
getContentGenerator
-
getMultipartBoundary
-
setMultipartBoundary
-