public abstract static class HttpServer.Response
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Map |
headerMap_ |
private int |
statusCode_ |
private java.lang.String |
statusPhrase_ |
Constructor and Description |
---|
Response(int statusCode,
java.lang.String statusPhrase,
java.util.Map headerMap)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map |
getHeaderMap()
Returns a map of key-value pairs representing HTTP response headers.
|
int |
getStatusCode()
Returns the 3-digit status code.
|
java.lang.String |
getStatusPhrase()
Returns the status phrase.
|
abstract void |
writeBody(java.io.OutputStream out)
Implemented to generate the bytes in the body of the response.
|
void |
writeResponse(java.io.OutputStream out)
Writes this response to an output stream in a way suitable for
replying to the client.
|
private final int statusCode_
private final java.lang.String statusPhrase_
private final java.util.Map headerMap_
public Response(int statusCode, java.lang.String statusPhrase, java.util.Map headerMap)
statusCode
- 3-digit status codestatusPhrase
- text string passed to client along
with the status codeheaderMap
- map of key-value pairs representing response
header information; should normally contain
at least a content-type keypublic int getStatusCode()
public java.lang.String getStatusPhrase()
public java.util.Map getHeaderMap()
HttpServer.getHeader(java.util.Map, java.lang.String)
utility method
can be used to interrogate the returned map.public abstract void writeBody(java.io.OutputStream out) throws java.io.IOException
out
- destination stream for body bytesjava.io.IOException
public void writeResponse(java.io.OutputStream out) throws java.io.IOException
writeBody(java.io.OutputStream)
is called.out
- destination streamjava.io.IOException