SMILA (incubation) API documentation

org.eclipse.smila.http.server.internal
Class HttpExchangeImpl

java.lang.Object
  extended by org.eclipse.smila.http.server.internal.HttpExchangeImpl
All Implemented Interfaces:
HttpExchange

public class HttpExchangeImpl
extends java.lang.Object
implements HttpExchange

The HttpExchange class implementation.


Constructor Summary
HttpExchangeImpl(Request req, HttpServletResponse resp, java.lang.String host, int port)
          create exchange object for a request-response-pair.
 
Method Summary
 java.lang.String getCharacterEncoding()
          Return the character encoding used in the request or null if none was set.
 java.lang.String getCompletePath()
          
 java.lang.String getHost()
          Return the host name of the HTTP server.
 java.util.Enumeration<java.lang.String> getParameterNames()
          Returns the a Enumeration of the parameter names.
 java.lang.String[] getParameterValues(java.lang.String name)
          Returns the values of a parameter name.
 int getPort()
          Return the port of the HTTP server.
 java.lang.String getProtocol()
          
 java.lang.String getQueryParameter(java.lang.String name)
          
 java.lang.String getQueryString()
          
 java.lang.String getRequestHeader(java.lang.String name)
          
 java.util.Enumeration<java.lang.String> getRequestHeaders()
          
 int getRequestIntHeader(java.lang.String name)
          
 java.lang.String getRequestMethod()
          
 java.io.InputStream getRequestStream()
          
 java.lang.String getRequestURI()
          
 java.io.OutputStream getResponseStream()
          Returns a stream for writing binary data in the response.
 void setResponseHeader(java.lang.String name, java.lang.String value)
          Sets a response header with the given name and value.
 void setResponseIntHeader(java.lang.String name, int value)
          Sets a response header with the given name and integer value.
 void setResponseStatus(int sc)
          Sets the response's status code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpExchangeImpl

public HttpExchangeImpl(Request req,
                        HttpServletResponse resp,
                        java.lang.String host,
                        int port)
create exchange object for a request-response-pair.

Parameters:
req - request
resp - response.
host - the host name of the HTTP server
port - the port of the HTTP server
Method Detail

getHost

public java.lang.String getHost()
Return the host name of the HTTP server.

Specified by:
getHost in interface HttpExchange
Returns:
the host name of the HTTP server.

getPort

public int getPort()
Return the port of the HTTP server.

Specified by:
getPort in interface HttpExchange
Returns:
the port of the HTTP server.

getProtocol

public java.lang.String getProtocol()

Specified by:
getProtocol in interface HttpExchange
Returns:
the HTTP protocol version string.

getRequestMethod

public java.lang.String getRequestMethod()

Specified by:
getRequestMethod in interface HttpExchange
Returns:
the name of the HTTP method, for example, GET, POST, or PUT.

getRequestHeader

public java.lang.String getRequestHeader(java.lang.String name)

Specified by:
getRequestHeader in interface HttpExchange
Parameters:
name - header name
Returns:
the value of the specified request header.

getRequestIntHeader

public int getRequestIntHeader(java.lang.String name)

Specified by:
getRequestIntHeader in interface HttpExchange
Parameters:
name - header name
Returns:
the integer value of the specified request header.

getRequestHeaders

public java.util.Enumeration<java.lang.String> getRequestHeaders()

Specified by:
getRequestHeaders in interface HttpExchange
Returns:
names of request headers.

getRequestURI

public java.lang.String getRequestURI()

Specified by:
getRequestURI in interface HttpExchange
Returns:
the part of the request's URL from the protocol name up to the query string in the first line of the HTTP request. Example: POST /aaa/bbb?x=y HTTP/1.1 => /aaa/bbb

getCompletePath

public java.lang.String getCompletePath()

Specified by:
getCompletePath in interface HttpExchange
Returns:
complete request path including query parameters and fragments.

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Return the character encoding used in the request or null if none was set.

Specified by:
getCharacterEncoding in interface HttpExchange
Returns:
the character encoding or null

getQueryString

public java.lang.String getQueryString()

Specified by:
getQueryString in interface HttpExchange
Returns:
the query string contained in the request URL after the path.

getQueryParameter

public java.lang.String getQueryParameter(java.lang.String name)

Specified by:
getQueryParameter in interface HttpExchange
Parameters:
name - parameter name
Returns:
the value of the specified parameter from the query string.

getRequestStream

public java.io.InputStream getRequestStream()
                                     throws java.io.IOException

Specified by:
getRequestStream in interface HttpExchange
Returns:
a stream for reading the request's body as binary data.
Throws:
java.io.IOException - IO error

setResponseStatus

public void setResponseStatus(int sc)
Sets the response's status code.

Specified by:
setResponseStatus in interface HttpExchange
Parameters:
sc - new status code

setResponseHeader

public void setResponseHeader(java.lang.String name,
                              java.lang.String value)
Sets a response header with the given name and value.

Specified by:
setResponseHeader in interface HttpExchange
Parameters:
name - header name
value - header value

setResponseIntHeader

public void setResponseIntHeader(java.lang.String name,
                                 int value)
Sets a response header with the given name and integer value.

Specified by:
setResponseIntHeader in interface HttpExchange
Parameters:
name - header name
value - int header value

getResponseStream

public java.io.OutputStream getResponseStream()
                                       throws java.io.IOException
Returns a stream for writing binary data in the response. Calling flush() on the stream commits the response.

Specified by:
getResponseStream in interface HttpExchange
Returns:
a stream for writing binary data in the response.
Throws:
java.io.IOException - IO error

getParameterNames

public java.util.Enumeration<java.lang.String> getParameterNames()
Returns the a Enumeration of the parameter names.

Specified by:
getParameterNames in interface HttpExchange
Returns:
a Enumeration of the parameter names

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Returns the values of a parameter name.

Specified by:
getParameterValues in interface HttpExchange
Parameters:
name - the name of the parameter
Returns:
the values of the parameter

SMILA (incubation) API documentation