Package org.astrogrid.samp.httpd

# Class HttpServer.Response

java.lang.Object
org.astrogrid.samp.httpd.HttpServer.Response

Enclosing class:
  `HttpServer`

public abstract static class HttpServer.Response extends Object
Represents a response to an HTTP request.

## Constructor Summary

Constructors
Constructor
Description
`Response(int statusCode, String statusPhrase, Map headerMap)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Map`
`getHeaderMap()`
Returns a map of key-value pairs representing HTTP response headers.
`int`
`getStatusCode()`
Returns the 3-digit status code.
`String`
`getStatusPhrase()`
Returns the status phrase.
`abstract void`
`writeBody(OutputStream out)`
Implemented to generate the bytes in the body of the response.
`void`
`writeResponse(OutputStream out)`
Writes this response to an output stream in a way suitable for replying to the client.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Response

public Response(int statusCode, String statusPhrase, Map headerMap)
Constructor.

Parameters:
  `statusCode` - 3-digit status code
  `statusPhrase` - text string passed to client along with the status code
  `headerMap` - map of key-value pairs representing response header information; should normally contain at least a content-type key

## Method Details

### getStatusCode

public int getStatusCode()
Returns the 3-digit status code.

Returns:
  status code

### getStatusPhrase

public String getStatusPhrase()
Returns the status phrase.

Returns:
  status phrase

### getHeaderMap

public 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); the `HttpServer.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(OutputStream out) throws IOException
Implemented to generate the bytes in the body of the response.

Parameters:
  `out` - destination stream for body bytes
Throws:
  `IOException`

### writeResponse

public void writeResponse(OutputStream out) throws IOException
Writes this response to an output stream in a way suitable for replying to the client. Status line and any headers are written, then `writeBody(java.io.OutputStream)` is called.

Parameters:
  `out` - destination stream
Throws:
  `IOException`