public class DefaultRequest<T> extends java.lang.Object implements Request<T>
This class is only intended for internal use inside the AWS client libraries. Callers shouldn't ever interact directly with objects of this class.
Modifier and Type | Field and Description |
---|---|
private java.io.InputStream |
content
An optional stream from which to read the request payload.
|
private java.net.URI |
endpoint
The service endpoint to which this request should be sent
|
private java.util.Map<HandlerContextKey<?>,java.lang.Object> |
handlerContext
Context associated with a request.
|
private java.util.Map<java.lang.String,java.lang.String> |
headers
Map of the headers included in this request
|
private HttpMethodName |
httpMethod
The HTTP method to use when sending this request.
|
private AWSRequestMetrics |
metrics
All AWS Request metrics are collected into this object.
|
private AmazonWebServiceRequest |
originalRequest
The original, user facing request object which this internal request
object is representing
|
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
parameters
Map of the parameters being sent as part of this request.
|
private java.lang.String |
resourcePath
The resource path being requested
|
private java.lang.String |
serviceName
The name of the service to which this request is being sent
|
private int |
timeOffset
An optional time offset to account for clock skew
|
Constructor and Description |
---|
DefaultRequest(AmazonWebServiceRequest originalRequest,
java.lang.String serviceName)
Constructs a new DefaultRequest with the specified service name and the
original, user facing request object.
|
DefaultRequest(java.lang.String serviceName)
Constructs a new DefaultRequest with the specified service name and no
specified original, user facing request object.
|
Modifier and Type | Method and Description |
---|---|
<X> void |
addHandlerContext(HandlerContextKey<X> key,
X value)
Adds a context to the request object that is visible
to all
RequestHandler2 . |
void |
addHeader(java.lang.String name,
java.lang.String value)
Sets the specified header for this request.
|
void |
addParameter(java.lang.String name,
java.lang.String value)
Adds the specified request parameter to this request.
|
void |
addParameters(java.lang.String name,
java.util.List<java.lang.String> values)
Adds the specified request parameter and list of values to this request.
|
AWSRequestMetrics |
getAWSRequestMetrics()
Returns the request metrics.
|
java.io.InputStream |
getContent()
Returns the optional stream containing the payload data to include for
this request.
|
java.io.InputStream |
getContentUnwrapped()
Returns the optional raw stream containing the payload data to include
for this request, with all progress stream wrappers.
|
java.net.URI |
getEndpoint()
Returns the service endpoint (ex: "https://ec2.amazonaws.com") to which
this request should be sent.
|
<X> X |
getHandlerContext(HandlerContextKey<X> key)
Return the context for the given key if present; else return null.
|
java.util.Map<java.lang.String,java.lang.String> |
getHeaders()
Returns a map of all the headers included in this request.
|
HttpMethodName |
getHttpMethod()
Returns the HTTP method (GET, POST, etc) to use when sending this
request.
|
AmazonWebServiceRequest |
getOriginalRequest()
Returns the original, user facing request object which this internal
request object is representing.
|
java.lang.Object |
getOriginalRequestObject()
Returns the original, user facing request object which this internal
request object is representing.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getParameters()
Returns a map of all parameters in this request.
|
ReadLimitInfo |
getReadLimitInfo()
Returns the read limit info about the original request.
|
java.lang.String |
getResourcePath()
Returns the path to the resource being requested.
|
java.lang.String |
getServiceName() |
int |
getTimeOffset()
Returns the optional value for time offset for this request.
|
void |
setAWSRequestMetrics(AWSRequestMetrics metrics)
Bind the request metrics to the request.
|
void |
setContent(java.io.InputStream content)
Sets the optional stream containing the payload data to include for this
request.
|
void |
setEndpoint(java.net.URI endpoint)
Sets the service endpoint (ex: "https://ec2.amazonaws.com") to which this
request should be sent.
|
void |
setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Sets all headers, clearing any existing ones.
|
void |
setHttpMethod(HttpMethodName httpMethod)
Sets the HTTP method (GET, POST, etc) to use when sending this request.
|
void |
setParameters(java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)
Sets all parameters, clearing any existing values.
|
void |
setResourcePath(java.lang.String resourcePath)
Sets the path to the resource being requested.
|
void |
setTimeOffset(int timeOffset)
Sets the optional value for time offset for this request.
|
java.lang.String |
toString() |
Request<T> |
withParameter(java.lang.String name,
java.lang.String value)
Adds the specified request parameter to this request, and returns the
updated request object.
|
Request<T> |
withTimeOffset(int timeOffset)
Sets the optional value for time offset for this request.
|
private java.lang.String resourcePath
private java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters
Note that a LinkedHashMap is used, since we want to preserve the insertion order so that members of a list parameter will still be ordered by their indices when they are marshalled into the query string. Lists values in this Map must use an implementation that allows null values to be present.
private java.util.Map<java.lang.String,java.lang.String> headers
private java.net.URI endpoint
private java.lang.String serviceName
private final AmazonWebServiceRequest originalRequest
private HttpMethodName httpMethod
private java.io.InputStream content
private int timeOffset
private AWSRequestMetrics metrics
private final java.util.Map<HandlerContextKey<?>,java.lang.Object> handlerContext
RequestHandler2
public DefaultRequest(AmazonWebServiceRequest originalRequest, java.lang.String serviceName)
serviceName
- The name of the service to which this request is being sent.originalRequest
- The original, user facing, AWS request being represented by
this internal request object.public DefaultRequest(java.lang.String serviceName)
serviceName
- The name of the service to which this request is being sent.public AmazonWebServiceRequest getOriginalRequest()
getOriginalRequest
in interface Request<T>
public void addHeader(java.lang.String name, java.lang.String value)
SignableRequest
addHeader
in interface SignableRequest<T>
name
- The name of the header to set.value
- The header's value.SignableRequest.addHeader(java.lang.String, java.lang.String)
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
SignableRequest
getHeaders
in interface SignableRequest<T>
SignableRequest.getHeaders()
public void setResourcePath(java.lang.String resourcePath)
Request
setResourcePath
in interface Request<T>
resourcePath
- The path to the resource being requested.Request.setResourcePath(java.lang.String)
public java.lang.String getResourcePath()
SignableRequest
getResourcePath
in interface SignableRequest<T>
SignableRequest.getResourcePath()
public void addParameter(java.lang.String name, java.lang.String value)
SignableRequest
addParameter
in interface SignableRequest<T>
name
- The name of the request parameter.value
- The value of the request parameter.SignableRequest.addParameter(java.lang.String, java.lang.String)
public void addParameters(java.lang.String name, java.util.List<java.lang.String> values)
Request
addParameters
in interface Request<T>
name
- The name of the request parameter.values
- The value of the request parameter.Request.addParameters(java.lang.String, java.util.List)
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getParameters()
SignableRequest
getParameters
in interface SignableRequest<T>
SignableRequest.getParameters()
public Request<T> withParameter(java.lang.String name, java.lang.String value)
Request
withParameter
in interface Request<T>
name
- The name of the request parameter.value
- The value of the request parameter.Request.withParameter(java.lang.String, java.lang.String)
public HttpMethodName getHttpMethod()
SignableRequest
getHttpMethod
in interface SignableRequest<T>
SignableRequest.getHttpMethod()
public void setHttpMethod(HttpMethodName httpMethod)
Request
setHttpMethod
in interface Request<T>
httpMethod
- The HTTP method to use when sending this request.Request.setHttpMethod(com.amazonaws.http.HttpMethodName)
public void setEndpoint(java.net.URI endpoint)
Request
setEndpoint
in interface Request<T>
endpoint
- The service endpoint to which this request should be sent.Request.setEndpoint(java.net.URI)
public java.net.URI getEndpoint()
SignableRequest
getEndpoint
in interface SignableRequest<T>
SignableRequest.getEndpoint()
public java.lang.String getServiceName()
getServiceName
in interface Request<T>
AmazonWebServiceClient.getServiceName()
which is used for
signing purpose.Request.getServiceName()
public java.io.InputStream getContent()
SignableRequest
getContent
in interface SignableRequest<T>
SignableRequest.getContent()
public void setContent(java.io.InputStream content)
SignableRequest
setContent
in interface SignableRequest<T>
content
- The optional stream containing the payload data to include for
this request.SignableRequest.setContent(java.io.InputStream)
public void setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Request
setHeaders
in interface Request<T>
Request.setHeaders(java.util.Map)
public void setParameters(java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)
Request
setParameters
in interface Request<T>
Request.setParameters(java.util.Map)
public int getTimeOffset()
SignableRequest
getTimeOffset
in interface SignableRequest<T>
SignableRequest.getTimeOffset()
public void setTimeOffset(int timeOffset)
Request
setTimeOffset
in interface Request<T>
timeOffset
- The optional value for time offset (in seconds) for this request.Request.setTimeOffset(int)
public Request<T> withTimeOffset(int timeOffset)
Request
withTimeOffset
in interface Request<T>
Request.setTimeOffset(int)
public java.lang.String toString()
toString
in class java.lang.Object
public AWSRequestMetrics getAWSRequestMetrics()
Request
getAWSRequestMetrics
in interface Request<T>
public void setAWSRequestMetrics(AWSRequestMetrics metrics)
Request
setAWSRequestMetrics
in interface Request<T>
public <X> void addHandlerContext(HandlerContextKey<X> key, X value)
Request
RequestHandler2
.
Note that, context added here will available only for the scope of
the request execution and will not be marshalled over the wire.addHandlerContext
in interface Request<T>
key
- the key for the property being set in the request.value
- the value for the property being set in the request.public <X> X getHandlerContext(HandlerContextKey<X> key)
Request
getHandlerContext
in interface Request<T>
key
- the key for the contextpublic java.io.InputStream getContentUnwrapped()
SignableRequest
getContentUnwrapped
in interface SignableRequest<T>
public ReadLimitInfo getReadLimitInfo()
SignableRequest
getReadLimitInfo
in interface SignableRequest<T>
public java.lang.Object getOriginalRequestObject()
SignableRequest
getOriginalRequestObject
in interface SignableRequest<T>
Object
.