com.ning.http.util
Class AsyncHttpProviderUtils

java.lang.Object
  extended by com.ning.http.util.AsyncHttpProviderUtils

public class AsyncHttpProviderUtils
extends Object

AsyncHttpProvider common utilities.

The cookies's handling code is from the Netty framework.


Field Summary
static String DEFAULT_CHARSET
           
protected static ThreadLocal<SimpleDateFormat[]> simpleDateFormat
           
 
Constructor Summary
AsyncHttpProviderUtils()
           
 
Method Summary
static void checkBodyParts(int statusCode, Collection<HttpResponseBodyPart> bodyParts)
           
static String constructUserAgent(Class<? extends AsyncHttpProvider> httpProvider)
           
static byte[] contentToByte(List<HttpResponseBodyPart> bodyParts)
           
static InputStream contentToInputStream(List<HttpResponseBodyPart> bodyParts)
           
static String contentToString(List<HttpResponseBodyPart> bodyParts, String charset)
           
static int convertExpireField(String timestring)
           
static MultipartRequestEntity createMultipartRequestEntity(List<Part> params, FluentStringsMap methodParams)
          This is quite ugly as our internal names are duplicated, but we build on top of HTTP Client implementation.
static URI createUri(String u)
           
static String encodeCookies(Collection<Cookie> cookies)
           
static SimpleDateFormat[] get()
           
static String getAuthority(URI uri)
           
static String getBaseUrl(String url)
           
static String getBaseUrl(URI uri)
           
static String getHost(URI uri)
           
static int getPort(URI uri)
           
static URI getRedirectUri(URI uri, String location)
           
static String keepAliveHeaderValue(AsyncHttpClientConfig config)
           
static String parseCharset(String contentType)
           
static Cookie parseCookie(String value)
           
static byte[] readFully(InputStream in, int[] lengthWrapper)
           
static void validateSupportedScheme(URI uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHARSET

public static final String DEFAULT_CHARSET
See Also:
Constant Field Values

simpleDateFormat

protected static final ThreadLocal<SimpleDateFormat[]> simpleDateFormat
Constructor Detail

AsyncHttpProviderUtils

public AsyncHttpProviderUtils()
Method Detail

get

public static final SimpleDateFormat[] get()

validateSupportedScheme

public static final void validateSupportedScheme(URI uri)

createUri

public static final URI createUri(String u)

getBaseUrl

public static String getBaseUrl(String url)

getBaseUrl

public static final String getBaseUrl(URI uri)

getAuthority

public static final String getAuthority(URI uri)

contentToString

public static final String contentToString(List<HttpResponseBodyPart> bodyParts,
                                           String charset)
                                    throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

contentToByte

public static final byte[] contentToByte(List<HttpResponseBodyPart> bodyParts)
                                  throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

contentToInputStream

public static final InputStream contentToInputStream(List<HttpResponseBodyPart> bodyParts)
                                              throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

getHost

public static final String getHost(URI uri)

getRedirectUri

public static final URI getRedirectUri(URI uri,
                                       String location)

getPort

public static final int getPort(URI uri)

createMultipartRequestEntity

public static final MultipartRequestEntity createMultipartRequestEntity(List<Part> params,
                                                                        FluentStringsMap methodParams)
                                                                 throws FileNotFoundException
This is quite ugly as our internal names are duplicated, but we build on top of HTTP Client implementation.

Parameters:
params -
methodParams -
Returns:
a MultipartRequestEntity.
Throws:
FileNotFoundException

readFully

public static final byte[] readFully(InputStream in,
                                     int[] lengthWrapper)
                              throws IOException
Throws:
IOException

encodeCookies

public static String encodeCookies(Collection<Cookie> cookies)

constructUserAgent

public static String constructUserAgent(Class<? extends AsyncHttpProvider> httpProvider)

parseCharset

public static String parseCharset(String contentType)

parseCookie

public static Cookie parseCookie(String value)

convertExpireField

public static int convertExpireField(String timestring)
                              throws Exception
Throws:
Exception

checkBodyParts

public static void checkBodyParts(int statusCode,
                                  Collection<HttpResponseBodyPart> bodyParts)

keepAliveHeaderValue

public static String keepAliveHeaderValue(AsyncHttpClientConfig config)


Copyright © 2013. All Rights Reserved.