com.heroku.api.http
Class HttpUtil

java.lang.Object
  extended by com.heroku.api.http.HttpUtil

public class HttpUtil
extends Object

HTTP related utilities.

Author:
Naaman Newbold

Constructor Summary
HttpUtil()
           
 
Method Summary
static String encodeIncludingSpecialCharacters(String toEncode)
          Some calls in the Heroku API decode strings in a different way from URLEncoder.
static String encodeParameters(RequestConfig config, Heroku.RequestKey... keys)
          URL encode request paramaters from a RequestConfig.
static byte[] getBytes(InputStream in)
          Converts an InputStream to a byte array
static String getUTF8String(byte[] in)
           
static RequestFailedException insufficientPrivileges(int code, byte[] bytes)
           
static UnsupportedOperationException noBody()
           
static URL toURL(String url)
           
static String urlencode(String toEncode, String messageIfFails)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpUtil

public HttpUtil()
Method Detail

encodeParameters

public static String encodeParameters(RequestConfig config,
                                      Heroku.RequestKey... keys)
URL encode request paramaters from a RequestConfig.

Parameters:
config - Name/value pairs for a HTTP request.
keys - List of keys in the config to encode.
Returns:
A string representation of encoded name/value parameters.

encodeIncludingSpecialCharacters

public static String encodeIncludingSpecialCharacters(String toEncode)
Some calls in the Heroku API decode strings in a different way from URLEncoder. This is a method for handling those special cases. First, urlencode() is called. Then, .-*_ are replaced with their hexadecimal equivalent.

Parameters:
config - Name/value pairs for a HTTP request.
keys - List of keys in the config to encode.
Returns:
A string representation of encoded parameters.

urlencode

public static String urlencode(String toEncode,
                               String messageIfFails)

noBody

public static UnsupportedOperationException noBody()

toURL

public static URL toURL(String url)

insufficientPrivileges

public static RequestFailedException insufficientPrivileges(int code,
                                                            byte[] bytes)

getBytes

public static byte[] getBytes(InputStream in)
Converts an InputStream to a byte array

Parameters:
in -
Returns:

getUTF8String

public static String getUTF8String(byte[] in)


Copyright © 2012. All Rights Reserved.