Package org.apache.xmlrpc.util
Class HttpUtil
- java.lang.Object
-
- org.apache.xmlrpc.util.HttpUtil
-
public class HttpUtil extends java.lang.Object
Provides utility functions useful in HTTP communications
-
-
Constructor Summary
Constructors Constructor Description HttpUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
encodeBasicAuthentication(java.lang.String pUser, java.lang.String pPassword, java.lang.String pEncoding)
Creates the Base64 encoded credentials for HTTP Basic Authentication.static java.lang.String
getNonIdentityTransferEncoding(java.lang.String pHeaderValue)
Returns, whether the HTTP header valuepHeaderValue
indicates, that another encoding than "identity" is used.static boolean
isUsingGzipEncoding(java.lang.String pHeaderValue)
Returns, whether the HTTP header valuepHeaderValue
indicates, that GZIP encoding is used or may be used.static boolean
isUsingGzipEncoding(java.util.Enumeration pValues)
Returns, whether the HTTP header values inpValues
indicate, that GZIP encoding is used or may be used.static void
parseAuthorization(XmlRpcHttpRequestConfigImpl pConfig, java.lang.String pLine)
Parses an "Authorization" header and adds the username and password topConfig
.static java.lang.String
readLine(java.io.InputStream pIn, byte[] pBuffer)
Reads a header line from the input streampIn
and converts it into a string.
-
-
-
Method Detail
-
encodeBasicAuthentication
public static java.lang.String encodeBasicAuthentication(java.lang.String pUser, java.lang.String pPassword, java.lang.String pEncoding) throws java.io.UnsupportedEncodingException
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:
java.io.UnsupportedEncodingException
- The encodingpEncoding
is invalid.
-
isUsingGzipEncoding
public static boolean isUsingGzipEncoding(java.lang.String pHeaderValue)
Returns, whether the HTTP header valuepHeaderValue
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.
-
getNonIdentityTransferEncoding
public static java.lang.String getNonIdentityTransferEncoding(java.lang.String pHeaderValue)
Returns, whether the HTTP header valuepHeaderValue
indicates, that another encoding than "identity" is used. This is typically the value of "Transfer-Encoding", or "TE".- Returns:
- Null, if the transfer encoding in use is "identity". Otherwise, another transfer encoding.
-
isUsingGzipEncoding
public static boolean isUsingGzipEncoding(java.util.Enumeration pValues)
Returns, whether the HTTP header values inpValues
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.
-
readLine
public static java.lang.String readLine(java.io.InputStream pIn, byte[] pBuffer) throws java.io.IOException
Reads a header line from the input streampIn
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:
java.io.IOException
- Reading the header line failed.
-
parseAuthorization
public static void parseAuthorization(XmlRpcHttpRequestConfigImpl pConfig, java.lang.String pLine)
Parses an "Authorization" header and adds the username and password topConfig
.- Parameters:
pConfig
- The request configuration being created.pLine
- The header being parsed, including the "basic" part.
-
-