public class Request
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected Authenticator |
authenticator
The authenticator.
|
protected HTTPConnection |
connection
The connection context in which this request is invoked.
|
protected java.lang.String |
method
The HTTP method to invoke.
|
protected java.lang.String |
path
The path identifying the resource.
|
protected long |
requestBodyNegotiationThreshold
Request body negotiation threshold for 100-continue expectations.
|
protected RequestBodyWriter |
requestBodyWriter
The request body provider.
|
protected Headers |
requestHeaders
The headers in this request.
|
protected ResponseBodyReader |
responseBodyReader
The response body reader.
|
protected java.util.Map |
responseHeaderHandlers
Map of response header handlers.
|
Modifier | Constructor and Description |
---|---|
protected |
Request(HTTPConnection connection,
java.lang.String method,
java.lang.String path)
Constructor for a new request.
|
Modifier and Type | Method and Description |
---|---|
Response |
dispatch()
Dispatches this request.
|
HTTPConnection |
getConnection()
Returns the connection associated with this request.
|
java.util.Date |
getDateHeader(java.lang.String name)
Returns the value of the specified header in this request as a date.
|
java.lang.String |
getHeader(java.lang.String name)
Returns the value of the specified header in this request.
|
Headers |
getHeaders()
Returns the headers in this request.
|
int |
getIntHeader(java.lang.String name)
Returns the value of the specified header in this request as an integer.
|
java.lang.String |
getMethod()
Returns the HTTP method to invoke.
|
java.lang.String |
getPath()
Returns the resource path.
|
java.lang.String |
getRequestURI()
Returns the full request-URI represented by this request, as specified
by HTTP/1.1.
|
void |
preauthenticate(java.lang.String scheme) |
void |
setAuthenticator(Authenticator authenticator)
Sets an authenticator that can be used to handle authentication
automatically.
|
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets the specified header in this request.
|
void |
setRequestBody(byte[] requestBody)
Convenience method to set the entire request body.
|
void |
setRequestBodyNegotiationThreshold(long threshold)
Sets the request body negotiation threshold.
|
void |
setRequestBodyWriter(RequestBodyWriter requestBodyWriter)
Sets the request body provider.
|
void |
setResponseBodyReader(ResponseBodyReader responseBodyReader)
Sets the response body reader.
|
void |
setResponseHeaderHandler(java.lang.String name,
ResponseHeaderHandler handler)
Sets a callback handler to be invoked for the specified header name.
|
protected final HTTPConnection connection
protected final java.lang.String method
protected final java.lang.String path
protected final Headers requestHeaders
protected RequestBodyWriter requestBodyWriter
protected long requestBodyNegotiationThreshold
protected ResponseBodyReader responseBodyReader
protected java.util.Map responseHeaderHandlers
protected Authenticator authenticator
protected Request(HTTPConnection connection, java.lang.String method, java.lang.String path)
connection
- the connection contextmethod
- the HTTP methodpath
- the resource path including query partpublic HTTPConnection getConnection()
connection
public java.lang.String getMethod()
method
public java.lang.String getPath()
path
public java.lang.String getRequestURI()
public Headers getHeaders()
public java.lang.String getHeader(java.lang.String name)
name
- the header namepublic int getIntHeader(java.lang.String name)
name
- the header namepublic java.util.Date getDateHeader(java.lang.String name)
name
- the header namepublic void setHeader(java.lang.String name, java.lang.String value)
name
- the header namevalue
- the header valuepublic void setRequestBody(byte[] requestBody)
requestBody
- the request body contentpublic void setRequestBodyWriter(RequestBodyWriter requestBodyWriter)
requestBodyWriter
- the handler used to obtain the request bodypublic void setResponseBodyReader(ResponseBodyReader responseBodyReader)
responseBodyReader
- the handler to receive notifications of
response body contentpublic void setResponseHeaderHandler(java.lang.String name, ResponseHeaderHandler handler)
name
- the header namehandler
- the handler to receive the value for the headerpublic void setAuthenticator(Authenticator authenticator)
authenticator
- the authenticatorpublic void setRequestBodyNegotiationThreshold(long threshold)
100-continue
expectation). This ensures that a large
request body is not sent when the server wouldn't have accepted it
anyway.threshold
- the body negotiation threshold, or <=0 to disable
request body negotation entirelypublic Response dispatch() throws java.io.IOException
java.io.IOException
- if an I/O error occurredpublic void preauthenticate(java.lang.String scheme) throws java.io.IOException
java.io.IOException