- All Known Implementing Classes:
DefaultHttpServerResponse
,GrizzlyHttpServerResponse
,JdkHttpResponse
,NettyHttpServerResponse
,UndertowHttpResponse
public interface HttpServerResponse
THe HttpServerResponse API.
This API delivers an abstraction over the HTTP response status line, the HTTP response headers and the HTTP response body.
- Author:
- Manfred Riem ([email protected])
-
Method Summary
Modifier and Type Method Description void
addHeader(java.lang.String name, java.lang.String value)
Add the header.default void
closeResponse()
Close the response.java.lang.String
getHeader(java.lang.String name)
Get the header.java.io.OutputStream
getOutputStream()
Get the output stream.void
setHeader(java.lang.String name, java.lang.String value)
Set the specified header.void
setStatus(int status)
Set the status.void
writeHeaders()
Write the headers.void
writeStatusLine()
Write the status line.
-
Method Details
-
addHeader
void addHeader(java.lang.String name, java.lang.String value)Add the header.- Parameters:
name
- the name.value
- the value.
-
closeResponse
default void closeResponse() throws java.io.IOExceptionClose the response.- Throws:
java.io.IOException
- when an I/O error occurs.
-
getHeader
java.lang.String getHeader(java.lang.String name)Get the header.- Parameters:
name
- the name.- Returns:
- the value, or null if not found.
-
getOutputStream
java.io.OutputStream getOutputStream()Get the output stream.- Returns:
- the output stream.
-
setHeader
void setHeader(java.lang.String name, java.lang.String value)Set the specified header.- Parameters:
name
- the header name.value
- the header value.
-
setStatus
void setStatus(int status)Set the status.- Parameters:
status
- the status.
-
writeHeaders
void writeHeaders() throws java.io.IOExceptionWrite the headers.- Throws:
java.io.IOException
- when an I/O error occurs.
-
writeStatusLine
void writeStatusLine() throws java.io.IOExceptionWrite the status line.- Throws:
java.io.IOException
- when an I/O error occurs.
-