public abstract class HttpExchange
extends java.lang.Object
A HttpExchange
must be closed to free or reuse
underlying resources. The effect of failing to close an exchange
is undefined.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
REQUEST_CIPHER_SUITE
Standard property: cipher suite value when the request is received
over HTTPS
|
static java.lang.String |
REQUEST_KEY_SIZE
Standard property: bit size of the algorithm when the request is
received over HTTPS
|
static java.lang.String |
REQUEST_X509CERTIFICATE
Standard property: A SSL certificate, if any, associated with the request
|
Constructor and Description |
---|
HttpExchange() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addResponseHeader(java.lang.String name,
java.lang.String value)
Adds a response header with the given name and value.
|
abstract void |
close()
This must be called to end an exchange.
|
abstract java.lang.Object |
getAttribute(java.lang.String name)
Returns an attribute that is associated with this
HttpExchange . |
abstract java.util.Set<java.lang.String> |
getAttributeNames()
Gives all the attribute names that are associated with
this
HttpExchange . |
abstract java.lang.String |
getContextPath()
Returns the context path of all the endpoints in an application.
|
abstract HttpContext |
getHttpContext()
Returns a
HttpContext for this exchange. |
abstract java.net.InetSocketAddress |
getLocalAddress()
Returns the unresolved local address on which the request was received.
|
abstract java.lang.String |
getPathInfo()
Returns the extra path information that follows the web service
path but precedes the query string in the request URI and will start
with a "/" character.
|
abstract java.lang.String |
getProtocol()
Returns the protocol string from the request in the form
protocol/majorVersion.minorVersion.
|
abstract java.lang.String |
getQueryString()
Returns the query string that is contained in the request URI
after the path.
|
abstract java.net.InetSocketAddress |
getRemoteAddress()
Returns the unresolved address of the remote entity invoking
this request.
|
abstract java.io.InputStream |
getRequestBody()
Returns a stream from which the request body can be read.
|
abstract java.lang.String |
getRequestHeader(java.lang.String name)
Returns the value of the specified request header.
|
abstract java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getRequestHeaders()
Returns an immutable Map containing the HTTP headers that were
included with this request.
|
abstract java.lang.String |
getRequestMethod()
Get the HTTP request method
|
abstract java.lang.String |
getRequestURI()
Returns the part of the request's URI from the protocol
name up to the query string in the first line of the HTTP request.
|
abstract java.io.OutputStream |
getResponseBody()
Returns a stream to which the response body must be
written.
|
abstract java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getResponseHeaders()
Returns a mutable Map into which the HTTP response headers can be stored
and which will be transmitted as part of this response.
|
abstract java.lang.String |
getScheme()
Returns the name of the scheme used to make this request,
for example: http, or https.
|
abstract java.security.Principal |
getUserPrincipal()
Returns the
Principal that represents the authenticated
user for this HttpExchange . |
abstract boolean |
isUserInRole(java.lang.String role)
Indicates whether an authenticated user is included in the specified
logical "role".
|
abstract void |
setStatus(int status)
Sets the HTTP status code for the response.
|
public static final java.lang.String REQUEST_CIPHER_SUITE
Type: String
public static final java.lang.String REQUEST_KEY_SIZE
Type: Integer
public static final java.lang.String REQUEST_X509CERTIFICATE
Type: java.security.cert.X509Certificate[] The order of this array is defined as being in ascending order of trust. The first certificate in the chain is the one set by the client, the next is the one used to authenticate the first, and so on.
public abstract java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestHeaders()
The keys in Map are case-insensitive.
public abstract java.lang.String getRequestHeader(java.lang.String name)
getRequestHeaders()
).name
- the name of the request headerpublic abstract java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders()
The keys in Map are case-insensitive.
public abstract void addResponseHeader(java.lang.String name, java.lang.String value)
getResponseHeaders()
).name
- the name of the headervalue
- the additional header value. If it contains octet string,
it should be encoded according to
RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)getResponseHeaders()
public abstract java.lang.String getRequestURI()
public abstract java.lang.String getContextPath()
Context path is used in computing the endpoint address. See
HttpContext.getPath()
HttpContext.getPath()
public abstract java.lang.String getRequestMethod()
public abstract HttpContext getHttpContext()
HttpContext
for this exchange.
Container matches the request with the associated Endpoint's HttpContextpublic abstract void close() throws java.io.IOException
java.io.IOException
- if any i/o errorpublic abstract java.io.InputStream getRequestBody() throws java.io.IOException
java.io.IOException
- if any i/o error during request processingpublic abstract java.io.OutputStream getResponseBody() throws java.io.IOException
setStatus(int)
) must be called prior to calling
this method. Multiple calls to this method (for the same exchange)
will return the same stream.java.io.IOException
- if any i/o error during response processingpublic abstract void setStatus(int status)
This method must be called prior to calling getResponseBody()
.
status
- the response code to sendgetResponseBody()
public abstract java.net.InetSocketAddress getRemoteAddress()
public abstract java.net.InetSocketAddress getLocalAddress()
public abstract java.lang.String getProtocol()
public abstract java.lang.String getScheme()
public abstract java.lang.String getPathInfo()
This can be used for MessageContext.PATH_INFO
null
if there is no extra path in the request URIpublic abstract java.lang.String getQueryString()
This can be used for MessageContext.QUERY_STRING
null
if the request URI doesn't have onepublic abstract java.lang.Object getAttribute(java.lang.String name)
HttpExchange
. JAX-WS handlers and endpoints may then
access the attribute via MessageContext
.
Servlet containers must expose MessageContext.SERVLET_CONTEXT
,
MessageContext.SERVLET_REQUEST
, and
MessageContext.SERVLET_RESPONSE
as attributes.
If the request has been received by the container using HTTPS, the
following information must be exposed as attributes. These attributes
are REQUEST_CIPHER_SUITE
, and REQUEST_KEY_SIZE
.
If there is a SSL certificate associated with the request, it must
be exposed using REQUEST_X509CERTIFICATE
name
- attribute namenull
if the attribute doesn't
existpublic abstract java.util.Set<java.lang.String> getAttributeNames()
HttpExchange
.getAttribute(String)
public abstract java.security.Principal getUserPrincipal()
Principal
that represents the authenticated
user for this HttpExchange
.null
if not authenticatedpublic abstract boolean isUserInRole(java.lang.String role)
role
- specifies the name of the roletrue
if the user making this request belongs to a
given role