Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.http;
 
 import java.net.URI;
 import java.util.Map;
 
 
 public class HttpRequest {
 
     private Map<StringStringparameters = new HashMap<StringString>();
     private Map<StringStringheaders = new HashMap<StringString>();
     private HttpMethodName methodName;
     private String serviceName;
     private URI endpoint;
     private String resourcePath;
     private InputStream inputStream;
     private AmazonWebServiceRequest originalRequest;

    
Construct request with http method name Supported methods are: GET POST DELETE HEAD PUT

Parameters:
methodName http method name
 
     public HttpRequest(HttpMethodName methodName) {
         this. = methodName;
     }

    
Returns http request method

Returns:
http request method
 
     public HttpMethodName getMethodName() {
         return ;
     }

    
Sets the name of the Amazon service this request is for.

Parameters:
serviceName The name of the Amazon service this request is for.
 
     public void setServiceName(String serviceName) {
         this. = serviceName;
     }

    
Returns the name of the Amazon service this request is for.

Returns:
The name of the Amazon service this request is for.
 
     public String getServiceName() {
         return ;
     }

    
Returns the service endpoint (ex: "https://ec2.amazonaws.com") to which this HTTP request should be sent.

Returns:
The service endpoint to which this HTTP request should be sent.
 
     public URI getEndpoint() {
         return ;
     }

    
Sets the service endpoint (ex: "https://ec2.amazonaws.com") to which this HTTP request should be sent.

Parameters:
endpoint The service endpoint to which this HTTP request should be sent.
 
     public void setEndpoint(URI endpoint) {
         this. = endpoint;
     }

    
Returns list of request parameters

Returns:
list of request parameters
    public Map<StringStringgetParameters() {
        return ;
    }

    
Returns a map of the headers associated with this request

Returns:
a map of the headers associated with this request
    public Map<StringStringgetHeaders() {
        return ;
    }

    
Adds the specified header name and value to this request.

Parameters:
name The name of the header.
value The value of the header.
    public void addHeader(String nameString value) {
        .put(namevalue);
    }

    
Removes header from request

Parameters:
name header name to remove
    public void removeHeader(String name) {
        this..remove(name);
    }
    public void addParameter(String nameString value) {
        this..put(namevalue);
    }
    public void setParameters(Map<StringStringparameters) {
        this. = parameters;
    }
    public HttpRequest withParameter(String nameString value) {
        addParameter(namevalue);
        return this;
    }

    
Returns the resource path associated with this request.

Returns:
The resource path associated with this request.
    public String getResourcePath() {
        return ;
    }

    
Sets the resource path associated with this request.

Parameters:
resourcePath The resource path associated with this request.
    public void setResourcePath(String resourcePath) {
        this. = resourcePath;
    }

    
Sets the input stream containing the content to include with this request.

Parameters:
inputStream The input stream containing the content to include with this request.
    public void setContent(InputStream inputStream) {
        this. = inputStream;
    }

    
Returns the input stream containing the content to include with this request.

Returns:
The input stream containing the content to include with this request.
    public InputStream getContent() {
        return ;
    }

    
Sets the original request, as constructed by the SDK user, for which this HTTP request is being executed.

Parameters:
request The original request constructed by the end user.
    public void setOriginalRequest(AmazonWebServiceRequest request) {
        this. = request;
    }

    
Returns the original request, as constructed by the SDK user, for which this HTTP request is being executed.

Returns:
request The original request constructed by the end user.
        return ;
    }
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append(getMethodName().toString() + " ");
        builder.append(getEndpoint().toString() + " ");
        builder.append("/"
                + (getResourcePath() != null ? getResourcePath() : "")
                + " ");
        if (!getParameters().isEmpty()) {
            builder.append("Parameters: (");
            for (String key : getParameters().keySet()) {
                String value = getParameters().get(key);
                builder.append(key + ": " + value + ", ");
            }
            builder.append(") ");
        }
        if (!getHeaders().isEmpty()) {
            builder.append("Headers: (");
            for (String key : getHeaders().keySet()) {
                String value = getHeaders().get(key);
                builder.append(key + ": " + value + ", ");
            }
            builder.append(") ");
        }
        return builder.toString();
    }
New to GrepCode? Check out our FAQ X