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
           
 
Constructor Summary
AsyncHttpProviderUtils()
           
 
Method Summary
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 MultipartRequestEntity createMultipartRequestEntity(List<Part> params, FluentCaseInsensitiveStringsMap requestHeaders)
          This is quite ugly as our internal names are duplicated, but we build on top of HTTP Client implementation.
static boolean followRedirect(AsyncHttpClientConfig config, Request request)
           
static String formParams2UTF8String(List<Param> params)
           
static String getAuthority(UriComponents uri)
           
static String getBaseUrl(UriComponents uri)
           
static int getDefaultPort(UriComponents uri)
           
static String getNonEmptyPath(UriComponents uri)
          Convenient for HTTP layer when targeting server root
static String keepAliveHeaderValue(AsyncHttpClientConfig config)
           
static String parseCharset(String contentType)
           
static byte[] readFully(InputStream in, int[] lengthWrapper)
           
static int requestTimeout(AsyncHttpClientConfig config, Request request)
           
static void validateSupportedScheme(UriComponents 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
Constructor Detail

AsyncHttpProviderUtils

public AsyncHttpProviderUtils()
Method Detail

validateSupportedScheme

public static final void validateSupportedScheme(UriComponents uri)

getBaseUrl

public static final String getBaseUrl(UriComponents uri)

getAuthority

public static final String getAuthority(UriComponents 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

getDefaultPort

public static final int getDefaultPort(UriComponents uri)

getNonEmptyPath

public static final String getNonEmptyPath(UriComponents uri)
Convenient for HTTP layer when targeting server root

Returns:
the raw path or "/" if it's null

createMultipartRequestEntity

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

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

readFully

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

constructUserAgent

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

parseCharset

public static String parseCharset(String contentType)

keepAliveHeaderValue

public static String keepAliveHeaderValue(AsyncHttpClientConfig config)

requestTimeout

public static int requestTimeout(AsyncHttpClientConfig config,
                                 Request request)

followRedirect

public static boolean followRedirect(AsyncHttpClientConfig config,
                                     Request request)

formParams2UTF8String

public static String formParams2UTF8String(List<Param> params)


Copyright © 2014. All Rights Reserved.