org.apache.xmlrpc.util

Class HttpUtil

public class HttpUtil extends Object

Provides utility functions useful in HTTP communications
Method Summary
static StringencodeBasicAuthentication(String pUser, String pPassword, String pEncoding)
Creates the Base64 encoded credentials for HTTP Basic Authentication.
static booleanisUsingGzipEncoding(String pHeaderValue)
Returns, whether the HTTP header value pHeaderValue indicates, that GZIP encoding is used or may be used.
static booleanisUsingGzipEncoding(Enumeration pValues)
Returns, whether the HTTP header values in pValues indicate, that GZIP encoding is used or may be used.
static voidparseAuthorization(XmlRpcHttpRequestConfigImpl pConfig, String pLine)
Parses an "Authorization" header and adds the username and password to pConfig.
static StringreadLine(InputStream pIn, byte[] pBuffer)
Reads a header line from the input stream pIn and converts it into a string.

Method Detail

encodeBasicAuthentication

public static String encodeBasicAuthentication(String pUser, String pPassword, String pEncoding)
Creates the Base64 encoded credentials for HTTP Basic Authentication.

Parameters: pUser User name, or null, if no Basic Authentication is being used. pPassword Users password, or null, if no Basic Authentication is being used. pEncoding Encoding being used for conversion of the credential string into a byte array.

Returns: Base64 encoded credentials, for use in the HTTP header

Throws: UnsupportedEncodingException The encoding pEncoding is invalid.

isUsingGzipEncoding

public static boolean isUsingGzipEncoding(String pHeaderValue)
Returns, whether the HTTP header value pHeaderValue indicates, that GZIP encoding is used or may be used.

Parameters: pHeaderValue The HTTP header value being parsed. This is typically the value of "Content-Encoding", or "Accept-Encoding".

Returns: True, if the header value suggests that GZIP encoding is or may be used.

isUsingGzipEncoding

public static boolean isUsingGzipEncoding(Enumeration pValues)
Returns, whether the HTTP header values in pValues indicate, that GZIP encoding is used or may be used.

Parameters: pValues The HTTP header values being parsed. These are typically the values of "Content-Encoding", or "Accept-Encoding".

Returns: True, if the header values suggests that GZIP encoding is or may be used.

parseAuthorization

public static void parseAuthorization(XmlRpcHttpRequestConfigImpl pConfig, String pLine)
Parses an "Authorization" header and adds the username and password to pConfig.

Parameters: pConfig The request configuration being created. pLine The header being parsed, including the "basic" part.

readLine

public static String readLine(InputStream pIn, byte[] pBuffer)
Reads a header line from the input stream pIn and converts it into a string.

Parameters: pIn The input stream being read. pBuffer A buffer being used for temporary storage. The buffers length is a limit of the header lines length.

Returns: Next header line or null, if no more header lines are available.

Throws: IOException Reading the header line failed.

Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.