Package io.milton.http
Interface Response
-
public interface Response
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classResponse.CacheControlResponsestatic classResponse.ContentEncodingstatic classResponse.ContentTypestatic interfaceResponse.Entitystatic classResponse.Headerstatic classResponse.Status
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Called to indicate that the request is completed.StringgetAcceptRanges()StringgetAccessControlAllowOrigin()Used for CORS responsesLonggetContentLength()StringgetContentTypeHeader()Response.EntitygetEntity()Map<String,String>getHeaders()StringgetNonStandardHeader(String code)OutputStreamgetOutputStream()Response.StatusgetStatus()voidsendError(Response.Status status, String message)Called by milton when an error occurs.voidsendRedirect(String url)Will set the status to moved_temporaruly and set the location header to the given urlvoidsetAcceptRanges(String s)voidsetAccessControlAllowOrigin(String s)voidsetAllowHeader(List<String> methodsAllowed)voidsetAuthenticateHeader(List<String> challenges)Must set multiple Authenticate headers, one for each challenge This will usually be one each for basic, digest, ntlm, etc Note that order might be significant to some clients, so should be preserved.voidsetCacheControlMaxAgeHeader(Long deltaSeconds)Set the cache control header to allow the resource to be cached for the given number of secondsvoidsetCacheControlNoCacheHeader()Set the cache control header to indicate that the resource should not be cachedvoidsetCacheControlPrivateMaxAgeHeader(Long deltaSeconds)voidsetContentEncodingHeader(Response.ContentEncoding encoding)voidsetContentLengthHeader(Long totalLength)voidsetContentRangeHeader(long start, long finish, Long totalLength)voidsetContentTypeHeader(String string)CookiesetCookie(Cookie cookie)ThesetCookiemethod is used to set a cookie value with the cookie name.CookiesetCookie(String name, String value)ThesetCookiemethod is used to set a cookie value with the cookie name.voidsetDateHeader(Date date)voidsetDavHeader(String string)voidsetEntity(Response.Entity entity)voidsetEtag(String uniqueId)voidsetExpiresHeader(Date expiresAt)voidsetLastModifiedHeader(Date date)voidsetLocationHeader(String redirectUrl)voidsetLockTokenHeader(String tokenId)voidsetNonStandardHeader(String code, String value)voidsetStatus(Response.Status status)voidsetVaryHeader(String string)Sets the Vary response header, necessary for response compression
-
-
-
Field Detail
-
HTTP
static final String HTTP
- See Also:
- Constant Field Values
-
IMAGE_JPG
static final String IMAGE_JPG
- See Also:
- Constant Field Values
-
MULTIPART
static final String MULTIPART
- See Also:
- Constant Field Values
-
XML
static final String XML
- See Also:
- Constant Field Values
-
-
Method Detail
-
getStatus
Response.Status getStatus()
-
getContentLength
Long getContentLength()
- Returns:
- - the content length which might have been set by a handler, or null if none has been set
-
setContentEncodingHeader
void setContentEncodingHeader(Response.ContentEncoding encoding)
-
setExpiresHeader
void setExpiresHeader(Date expiresAt)
-
setLockTokenHeader
void setLockTokenHeader(String tokenId)
-
setAuthenticateHeader
void setAuthenticateHeader(List<String> challenges)
Must set multiple Authenticate headers, one for each challenge This will usually be one each for basic, digest, ntlm, etc Note that order might be significant to some clients, so should be preserved. ie list item zero should be first.- Parameters:
challenges- - a list of http authentication challenges
-
setStatus
void setStatus(Response.Status status)
-
setEtag
void setEtag(String uniqueId)
-
setContentRangeHeader
void setContentRangeHeader(long start, long finish, Long totalLength)
-
setContentLengthHeader
void setContentLengthHeader(Long totalLength)
-
setContentTypeHeader
void setContentTypeHeader(String string)
-
getContentTypeHeader
String getContentTypeHeader()
-
getEntity
Response.Entity getEntity()
-
setEntity
void setEntity(Response.Entity entity)
-
setCacheControlMaxAgeHeader
void setCacheControlMaxAgeHeader(Long deltaSeconds)
Set the cache control header to allow the resource to be cached for the given number of seconds- Parameters:
deltaSeconds- - must not be null
-
setCacheControlPrivateMaxAgeHeader
void setCacheControlPrivateMaxAgeHeader(Long deltaSeconds)
-
setCacheControlNoCacheHeader
void setCacheControlNoCacheHeader()
Set the cache control header to indicate that the resource should not be cached
-
setLastModifiedHeader
void setLastModifiedHeader(Date date)
-
setDavHeader
void setDavHeader(String string)
-
getOutputStream
OutputStream getOutputStream()
-
setLocationHeader
void setLocationHeader(String redirectUrl)
-
setVaryHeader
void setVaryHeader(String string)
Sets the Vary response header, necessary for response compression- Parameters:
string-
-
setDateHeader
void setDateHeader(Date date)
-
getAccessControlAllowOrigin
String getAccessControlAllowOrigin()
Used for CORS responses- Returns:
-
setAccessControlAllowOrigin
void setAccessControlAllowOrigin(String s)
-
getAcceptRanges
String getAcceptRanges()
-
setAcceptRanges
void setAcceptRanges(String s)
-
close
void close()
Called to indicate that the request is completed. Some response implementations might choose to close the http connection, while others which implement pipelining might not
-
sendError
void sendError(Response.Status status, String message)
Called by milton when an error occurs. The underlying HTTP provider should choose to close the HTTP connection, because the amount of data already sent might not be consistent with the content length header which may have already been sent- Parameters:
status-message-
-
sendRedirect
void sendRedirect(String url)
Will set the status to moved_temporaruly and set the location header to the given url- Parameters:
url-
-
setCookie
Cookie setCookie(Cookie cookie)
ThesetCookiemethod is used to set a cookie value with the cookie name. This will add a cookie to the response stored under the name of the cookie, when this is committed it will be added as a Set-Cookie header to the resulting response.- Parameters:
cookie- this is the cookie to be added to the response- Returns:
- returns the cookie that has been set in the response
-
setCookie
Cookie setCookie(String name, String value)
ThesetCookiemethod is used to set a cookie value with the cookie name. This will add a cookie to the response stored under the name of the cookie, when this is committed it will be added as a Set-Cookie header to the resulting response. This is a convenience method that avoids cookie creation.- Parameters:
name- this is the cookie to be added to the responsevalue- this is the cookie value that is to be used- Returns:
- returns the cookie that has been set in the response
-
-