Top Description Inners Fields Constructors Methods
org.springframework.http.server

public Class ServletServerHttpResponse

extends Object
implements ServerHttpResponse
Class Inheritance
All Implemented Interfaces
org.springframework.http.server.ServerHttpResponse, java.io.Closeable, java.lang.AutoCloseable, java.io.Flushable, org.springframework.http.HttpOutputMessage, org.springframework.http.HttpMessage
Imports
java.io.IOException, .OutputStream, java.util.ArrayList, .Collection, .Collections, .List, jakarta.servlet.http.HttpServletResponse, org.springframework.http.HttpHeaders, .HttpStatusCode, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils

ServerHttpResponse implementation that is based on a HttpServletResponse.
Authors
Arjen Poutsma, Rossen Stoyanchev
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ServletServerHttpResponse.ServletResponseHttpHeaders

Extends HttpHeaders with the ability to look up headers already present in the underlying HttpServletResponse.

Field Summary

Modifier and TypeField and Description
private boolean
private final HttpHeaders
private boolean
private HttpHeaders
private final HttpServletResponse

Constructor Summary

AccessConstructor and Description
public
ServletServerHttpResponse(HttpServletResponse
the servlet response
servletResponse
)

Construct a new instance of the ServletServerHttpResponse based on the given HttpServletResponse.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements org.springframework.http.server.ServerHttpResponse.close.

Close this response, freeing any resources created.

public void
flush()

Implements org.springframework.http.server.ServerHttpResponse.flush.

Ensure that the headers and the content of the response are written out.

public OutputStream
getBody()

Implements org.springframework.http.HttpOutputMessage.getBody.

Return the body of the message as an output stream.

public HttpHeaders
getHeaders()

Implements org.springframework.http.HttpMessage.getHeaders.

Return the headers of this message.

public HttpServletResponse
getServletResponse()

Return the HttpServletResponse this object is based on.

public void
setStatusCode(HttpStatusCode
the HTTP status as an HttpStatus enum value
status
)

Implements org.springframework.http.server.ServerHttpResponse.setStatusCode.

Set the HTTP status code of the response.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bodyUsedback to summary
private boolean bodyUsed
headersback to summary
private final HttpHeaders headers
headersWrittenback to summary
private boolean headersWritten
readOnlyHeadersback to summary
private HttpHeaders readOnlyHeaders
Annotations
@Nullable
servletResponseback to summary
private final HttpServletResponse servletResponse

Constructor Detail

ServletServerHttpResponseback to summary
public ServletServerHttpResponse(HttpServletResponse servletResponse)

Construct a new instance of the ServletServerHttpResponse based on the given HttpServletResponse.

Parameters
servletResponse:HttpServletResponse

the servlet response

Method Detail

closeback to summary
public void close()

Implements org.springframework.http.server.ServerHttpResponse.close.

Doc from org.springframework.http.server.ServerHttpResponse.close.

Close this response, freeing any resources created.

Annotations
@Override
flushback to summary
public void flush() throws IOException

Implements org.springframework.http.server.ServerHttpResponse.flush.

Doc from org.springframework.http.server.ServerHttpResponse.flush.

Ensure that the headers and the content of the response are written out.

After the first flush, headers can no longer be changed. Only further content writing and content flushing is possible.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Flushable.flush.

If an I/O error occurs

getBodyback to summary
public OutputStream getBody() throws IOException

Implements org.springframework.http.HttpOutputMessage.getBody.

Doc from org.springframework.http.HttpOutputMessage.getBody.

Return the body of the message as an output stream.

Returns:OutputStream

the output stream body (never null)

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
getHeadersback to summary
public HttpHeaders getHeaders()

Implements org.springframework.http.HttpMessage.getHeaders.

Doc from org.springframework.http.HttpMessage.getHeaders.

Return the headers of this message.

Returns:HttpHeaders

a corresponding HttpHeaders object (never null)

Annotations
@Override
getServletResponseback to summary
public HttpServletResponse getServletResponse()

Return the HttpServletResponse this object is based on.

setStatusCodeback to summary
public void setStatusCode(HttpStatusCode status)

Implements org.springframework.http.server.ServerHttpResponse.setStatusCode.

Doc from org.springframework.http.server.ServerHttpResponse.setStatusCode.

Set the HTTP status code of the response.

Parameters
status:HttpStatusCode

the HTTP status as an HttpStatus enum value

Annotations
@Override
writeHeadersback to summary
private void writeHeaders()
org.springframework.http.server back to summary

private Class ServletServerHttpResponse.ServletResponseHttpHeaders

extends HttpHeaders
Class Inheritance

Extends HttpHeaders with the ability to look up headers already present in the underlying HttpServletResponse.

The intent is merely to expose what is available through the HttpServletResponse i.e. the ability to look up specific header values by name. All other map-related operations (e.g. iteration, removal, etc) apply only to values added directly through HttpHeaders methods.

Since
4.0.3

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from org.springframework.http.HttpHeaders:
ACCEPTACCEPT_CHARSETACCEPT_ENCODINGACCEPT_LANGUAGEACCEPT_PATCHACCEPT_RANGESACCESS_CONTROL_ALLOW_CREDENTIALSACCESS_CONTROL_ALLOW_HEADERSACCESS_CONTROL_ALLOW_METHODSACCESS_CONTROL_ALLOW_ORIGINACCESS_CONTROL_EXPOSE_HEADERSACCESS_CONTROL_MAX_AGEACCESS_CONTROL_REQUEST_HEADERSACCESS_CONTROL_REQUEST_METHODAGEALLOWAUTHORIZATIONCACHE_CONTROLCONNECTIONCONTENT_DISPOSITIONCONTENT_ENCODINGCONTENT_LANGUAGECONTENT_LENGTHCONTENT_LOCATIONCONTENT_RANGECONTENT_TYPECOOKIEDATEEMPTYETAGEXPECTEXPIRESFROMHOSTIF_MATCHIF_MODIFIED_SINCEIF_NONE_MATCHIF_RANGEIF_UNMODIFIED_SINCELAST_MODIFIEDLINKLOCATIONMAX_FORWARDSORIGINPRAGMAPROXY_AUTHENTICATEPROXY_AUTHORIZATIONRANGEREFERERRETRY_AFTERSERVERSET_COOKIESET_COOKIE2TETRAILERTRANSFER_ENCODINGUPGRADEUSER_AGENTVARYVIAWARNINGWWW_AUTHENTICATE

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
containsKey(Object
key whose presence in this map is to be tested
key
)

Overrides org.springframework.http.HttpHeaders.containsKey.

Implements java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.

public List<String>
get(Object
the key whose associated value is to be returned
key
)

Overrides org.springframework.http.HttpHeaders.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

public String
getFirst(String
the header name
headerName
)

Overrides org.springframework.http.HttpHeaders.getFirst.

Implements org.springframework.util.MultiValueMap.getFirst.

Return the first header value for the given header name, if any.

Inherited from org.springframework.http.HttpHeaders:
addaddAlladdAllclearclearContentHeaderscontainsValueencodeBasicAuthentrySetequalsforEachformatHeadersgetAcceptgetAcceptCharsetgetAcceptLanguagegetAcceptLanguageAsLocalesgetAcceptPatchgetAccessControlAllowCredentialsgetAccessControlAllowHeadersgetAccessControlAllowMethodsgetAccessControlAllowOrigingetAccessControlExposeHeadersgetAccessControlMaxAgegetAccessControlRequestHeadersgetAccessControlRequestMethodgetAllowgetCacheControlgetConnectiongetContentDispositiongetContentLanguagegetContentLengthgetContentTypegetDategetETaggetETagValuesAsListgetExpiresgetFieldValuesgetFirstDategetFirstZonedDateTimegetHostgetIfMatchgetIfModifiedSincegetIfNoneMatchgetIfUnmodifiedSincegetLastModifiedgetLocationgetOrEmptygetOrigingetPragmagetRangegetUpgradegetValuesAsListgetVaryhashCodeisEmptykeySetputputAllputIfAbsentreadOnlyHttpHeadersreadOnlyHttpHeadersremovesetsetAcceptsetAcceptCharsetsetAcceptLanguagesetAcceptLanguageAsLocalessetAcceptPatchsetAccessControlAllowCredentialssetAccessControlAllowHeaderssetAccessControlAllowMethodssetAccessControlAllowOriginsetAccessControlExposeHeaderssetAccessControlMaxAgesetAccessControlMaxAgesetAccessControlRequestHeaderssetAccessControlRequestMethodsetAllsetAllowsetBasicAuthsetBasicAuthsetBasicAuthsetBearerAuthsetCacheControlsetCacheControlsetConnectionsetConnectionsetContentDispositionsetContentDispositionFormDatasetContentLanguagesetContentLengthsetContentTypesetDatesetDatesetDatesetDatesetETagsetExpiressetExpiressetExpiressetHostsetIfMatchsetIfMatchsetIfModifiedSincesetIfModifiedSincesetIfModifiedSincesetIfNoneMatchsetIfNoneMatchsetIfUnmodifiedSincesetIfUnmodifiedSincesetIfUnmodifiedSincesetInstantsetLastModifiedsetLastModifiedsetLastModifiedsetLocationsetOriginsetPragmasetRangesetUpgradesetVarysetZonedDateTimesizetoCommaDelimitedStringtoSingleValueMaptoStringvalueswritableHttpHeaders

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.springframework.http.HttpHeaders.serialVersionUID.

Constructor Detail

ServletResponseHttpHeadersback to summary
private ServletResponseHttpHeaders()

Method Detail

containsKeyback to summary
public boolean containsKey(Object key)

Overrides org.springframework.http.HttpHeaders.containsKey.

Implements java.util.Map.containsKey.

Doc from java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that Objects.equals(key, k). (There can be at most one such mapping.)

Parameters
key:Object

key whose presence in this map is to be tested

Returns:boolean

true if this map contains a mapping for the specified key

Annotations
@Override
getback to summary
public List<String> get(Object key)

Overrides org.springframework.http.HttpHeaders.get.

Implements java.util.Map.get.

Doc from java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
key:Object

the key whose associated value is to be returned

Returns:List<String>

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override
getFirstback to summary
public String getFirst(String headerName)

Overrides org.springframework.http.HttpHeaders.getFirst.

Implements org.springframework.util.MultiValueMap.getFirst.

Doc from org.springframework.http.HttpHeaders.getFirst.

Return the first header value for the given header name, if any.

Parameters
headerName:String

the header name

Returns:String

the first header value, or null if none

Annotations
@Override
@Nullable