com.amazonaws.util
Class HttpUtils

java.lang.Object
  extended by com.amazonaws.util.HttpUtils

public class HttpUtils
extends java.lang.Object


Constructor Summary
HttpUtils()
           
 
Method Summary
static java.lang.String appendUri(java.lang.String baseUri, java.lang.String path)
          Append the given path to the given baseUri.
static java.lang.String appendUri(java.lang.String baseUri, java.lang.String path, boolean escapeDoubleSlash)
          Append the given path to the given baseUri.
static java.lang.String encodeParameters(Request<?> request)
          Creates an encoded query string from all the parameters in the specified request.
static java.io.InputStream fetchFile(java.net.URI uri, ClientConfiguration config)
          Fetches a file from the URI given and returns an input stream to it.
static boolean isUsingNonDefaultPort(java.net.URI uri)
          Returns true if the specified URI is using a non-standard port (i.e.
static java.lang.String urlEncode(java.lang.String value, boolean path)
          Encode a string for use in the path of a URL; uses URLEncoder.encode, (which encodes a string for use in the query portion of a URL), then applies some postfilters to fix things up per the RFC.
static boolean usePayloadForQueryParameters(Request<?> request)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpUtils

public HttpUtils()
Method Detail

urlEncode

public static java.lang.String urlEncode(java.lang.String value,
                                         boolean path)
Encode a string for use in the path of a URL; uses URLEncoder.encode, (which encodes a string for use in the query portion of a URL), then applies some postfilters to fix things up per the RFC. Can optionally handle strings which are meant to encode a path (ie include '/'es which should NOT be escaped).

Parameters:
value - the value to encode
path - true if the value is intended to represent a path
Returns:
the encoded value

isUsingNonDefaultPort

public static boolean isUsingNonDefaultPort(java.net.URI uri)
Returns true if the specified URI is using a non-standard port (i.e. any port other than 80 for HTTP URIs or any port other than 443 for HTTPS URIs).

Parameters:
uri -
Returns:
True if the specified URI is using a non-standard port, otherwise false.

usePayloadForQueryParameters

public static boolean usePayloadForQueryParameters(Request<?> request)

encodeParameters

public static java.lang.String encodeParameters(Request<?> request)
Creates an encoded query string from all the parameters in the specified request.

Parameters:
request - The request containing the parameters to encode.
Returns:
Null if no parameters were present, otherwise the encoded query string for the parameters present in the specified request.

appendUri

public static java.lang.String appendUri(java.lang.String baseUri,
                                         java.lang.String path)
Append the given path to the given baseUri. By default, all slash characters in path will not be url-encoded.


appendUri

public static java.lang.String appendUri(java.lang.String baseUri,
                                         java.lang.String path,
                                         boolean escapeDoubleSlash)
Append the given path to the given baseUri.

This method will encode the given path but not the given baseUri.

Parameters:
baseUri - The URI to append to (required, may be relative)
path - The path to append (may be null or empty)
escapeDoubleSlash - Whether double-slash in the path should be escaped to "/%2F"
Returns:
The baseUri with the (encoded) path appended

fetchFile

public static java.io.InputStream fetchFile(java.net.URI uri,
                                            ClientConfiguration config)
                                     throws java.io.IOException
Fetches a file from the URI given and returns an input stream to it.

Parameters:
uri - the uri of the file to fetch
config - optional configuration overrides
Returns:
an InputStream containing the retrieved data
Throws:
java.io.IOException - on error


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.