Package org.springframework.http.server
Class ServletServerHttpResponse
java.lang.Object
org.springframework.http.server.ServletServerHttpResponse
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,HttpMessage
,HttpOutputMessage
,ServerHttpResponse
ServerHttpResponse
implementation that is based on a HttpServletResponse
.- Since:
- 3.0
- Author:
- Arjen Poutsma, Rossen Stoyanchev
-
Constructor Summary
ConstructorDescriptionServletServerHttpResponse
(HttpServletResponse servletResponse) Construct a new instance of the ServletServerHttpResponse based on the givenHttpServletResponse
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this response, freeing any resources created.void
flush()
Ensure that the headers and the content of the response are written out.getBody()
Return the body of the message as an output stream.Return the headers of this message.Return theHttpServletResponse
this object is based on.void
setStatusCode
(HttpStatusCode status) Set the HTTP status code of the response.
-
Constructor Details
-
ServletServerHttpResponse
Construct a new instance of the ServletServerHttpResponse based on the givenHttpServletResponse
.- Parameters:
servletResponse
- the servlet response
-
-
Method Details
-
getServletResponse
Return theHttpServletResponse
this object is based on. -
setStatusCode
Description copied from interface:ServerHttpResponse
Set the HTTP status code of the response.- Specified by:
setStatusCode
in interfaceServerHttpResponse
- Parameters:
status
- the HTTP status as an HttpStatus enum value
-
getHeaders
Description copied from interface:HttpMessage
Return the headers of this message.- Specified by:
getHeaders
in interfaceHttpMessage
- Returns:
- a corresponding HttpHeaders object (never
null
)
-
getBody
Description copied from interface:HttpOutputMessage
Return the body of the message as an output stream.- Specified by:
getBody
in interfaceHttpOutputMessage
- Returns:
- the output stream body (never
null
) - Throws:
IOException
- in case of I/O errors
-
flush
Description copied from interface:ServerHttpResponse
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.
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in interfaceServerHttpResponse
- Throws:
IOException
-
close
public void close()Description copied from interface:ServerHttpResponse
Close this response, freeing any resources created.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceServerHttpResponse
-