public class HttpMessageUtils extends Object
Important notice on Reason Phrase:
Modifier and Type | Field and Description |
---|---|
static int |
UNKNOWN_STATUS_CODE
A HTTP status code used to indicate that the actual response status code is not known at time of message
generation.
|
Constructor and Description |
---|
HttpMessageUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
formatAuthorizationMessage(String url,
int statusCode,
String reasonPhrase,
ProxyInfo proxyInfo)
Format a consistent message for HTTP related
AuthorizationException . |
static String |
formatResourceDoesNotExistMessage(String url,
int statusCode,
String reasonPhrase,
ProxyInfo proxyInfo)
Format a consistent message for HTTP related
ResourceDoesNotExistException . |
static String |
formatTransferDebugMessage(String url,
int statusCode,
String reasonPhrase,
ProxyInfo proxyInfo)
Format a consistent HTTP transfer debug message combining URL, status code, reason phrase and HTTP
proxy server info.
|
static String |
formatTransferFailedMessage(String url,
int statusCode,
String reasonPhrase,
ProxyInfo proxyInfo)
Format a consistent message for HTTP related
TransferFailedException . |
static String |
formatTransferFailedMessage(String url,
ProxyInfo proxyInfo)
Format a consistent message for HTTP related
TransferFailedException . |
public static final int UNKNOWN_STATUS_CODE
public HttpMessageUtils()
public static String formatTransferDebugMessage(String url, int statusCode, String reasonPhrase, ProxyInfo proxyInfo)
URL will always be included in the message. A status code other than UNKNOWN_STATUS_CODE
will be
included. A reason phrase will only be included if non-empty and status code is not UNKNOWN_STATUS_CODE
.
Proxy information will only be included if not null.
url
- the required non-null URL associated with the messagestatusCode
- an HTTP response status codereasonPhrase
- an HTTP reason phraseproxyInfo
- proxy server used during the transfer, may be null if none usedNullPointerException
- if url is nullpublic static String formatTransferFailedMessage(String url, ProxyInfo proxyInfo)
TransferFailedException
.
This variation typically used in cases where there is no HTTP transfer response data to extract status code and
reason phrase from. Equivalent to calling formatTransferFailedMessage(String, int, String, ProxyInfo)
with UNKNOWN_STATUS_CODE
and null reason phrase.
url
- the URL associated with the messageproxyInfo
- proxy server used during the transfer, may be null if none usedpublic static String formatTransferFailedMessage(String url, int statusCode, String reasonPhrase, ProxyInfo proxyInfo)
TransferFailedException
.url
- the URL associated with the messagestatusCode
- an HTTP response status code or UNKNOWN_STATUS_CODE
reasonPhrase
- an HTTP status line reason phrase or null if the reason phrase unknownproxyInfo
- proxy server used during the transfer, may be null if none usedpublic static String formatAuthorizationMessage(String url, int statusCode, String reasonPhrase, ProxyInfo proxyInfo)
AuthorizationException
.
The message will always include the URL and status code provided. If empty, the reason phrase is substituted with
a common reason based on status code. ProxyInfo
is only included in the message if not null.
url
- the URL associated with the messagestatusCode
- an HTTP response status code related to authreasonPhrase
- an HTTP status line reason phraseproxyInfo
- proxy server used during the transfer, may be null if none usedAuthorizationException
public static String formatResourceDoesNotExistMessage(String url, int statusCode, String reasonPhrase, ProxyInfo proxyInfo)
ResourceDoesNotExistException
.
The message will always include the URL and status code provided. If empty, the reason phrase is substituted with
the commonly used reason phrases per status code. ProxyInfo
is only included if not null.
url
- the URL associated with the messagestatusCode
- an HTTP response status code related to resources not being foundreasonPhrase
- an HTTP status line reason phraseproxyInfo
- proxy server used during the transfer, may be null if none usedResourceDoesNotExistException
Copyright © 2003–2022 The Apache Software Foundation. All rights reserved.