Package org.astrogrid.samp.httpd
Class HttpServer.Response
- java.lang.Object
-
- org.astrogrid.samp.httpd.HttpServer.Response
-
- Direct Known Subclasses:
LoggingCorsHttpServer.LoggedResponse
,XmlLoggingInternalServer.LoggingResponse
- Enclosing class:
- HttpServer
public abstract static class HttpServer.Response extends java.lang.Object
Represents a response to an HTTP request.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map
headerMap_
private int
statusCode_
private java.lang.String
statusPhrase_
-
Constructor Summary
Constructors Constructor Description Response(int statusCode, java.lang.String statusPhrase, java.util.Map headerMap)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Constructor Detail
-
Response
public Response(int statusCode, java.lang.String statusPhrase, java.util.Map headerMap)
Constructor.- Parameters:
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 key
-
-
Method Detail
-
getStatusCode
public int getStatusCode()
Returns the 3-digit status code.- Returns:
- status code
-
getStatusPhrase
public java.lang.String getStatusPhrase()
Returns the status phrase.- Returns:
- status phrase
-
getHeaderMap
public java.util.Map getHeaderMap()
Returns a map of key-value pairs representing HTTP response headers. Note that for HTTP usage, header keys are case-insensitive (RFC2616 sec 4.2); theHttpServer.getHeader(java.util.Map, java.lang.String)
utility method can be used to interrogate the returned map.- Returns:
- header map
-
writeBody
public abstract void writeBody(java.io.OutputStream out) throws java.io.IOException
Implemented to generate the bytes in the body of the response.- Parameters:
out
- destination stream for body bytes- Throws:
java.io.IOException
-
writeResponse
public void writeResponse(java.io.OutputStream out) throws java.io.IOException
Writes this response to an output stream in a way suitable for replying to the client. Status line and any headers are written, thenwriteBody(java.io.OutputStream)
is called.- Parameters:
out
- destination stream- Throws:
java.io.IOException
-
-