Class HttpMessageUtils
Important notice on Reason Phrase:
- reason phrase was defined by initial HTTP/1.1 RFC 2616: The Reason-Phrase is intended to give a short textual description of the Status-Code. The Status-Code is intended for use by automata and the Reason-Phrase is intended for the human user. The client is not required to examine or display the Reason- Phrase.
- it has been later largely deprecated in the updated HTTP/1.1 in RFC 7230: The reason-phrase element exists for the sole purpose of providing a textual description associated with the numeric status code, mostly out of deference to earlier Internet application protocols that were more frequently used with interactive text clients. A client SHOULD ignore the reason-phrase content.
- it has been removed from HTTP/2 in RFC 7540: HTTP/2 does not define a way to carry the version or reason phrase that is included in an HTTP/1.1 status line..
- Since:
- 3.3.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
A HTTP status code used to indicate that the actual response status code is not known at time of message generation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
formatAuthorizationMessage
(String url, int statusCode, String reasonPhrase, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo) Format a consistent message for HTTP relatedAuthorizationException
.static String
formatResourceDoesNotExistMessage
(String url, int statusCode, String reasonPhrase, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo) Format a consistent message for HTTP relatedResourceDoesNotExistException
.static String
formatTransferDebugMessage
(String url, int statusCode, String reasonPhrase, org.apache.maven.wagon.proxy.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, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo) Format a consistent message for HTTP relatedTransferFailedException
.static String
formatTransferFailedMessage
(String url, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo) Format a consistent message for HTTP relatedTransferFailedException
.
-
Field Details
-
UNKNOWN_STATUS_CODE
public static final int UNKNOWN_STATUS_CODEA HTTP status code used to indicate that the actual response status code is not known at time of message generation.- See Also:
-
-
Constructor Details
-
HttpMessageUtils
public HttpMessageUtils()
-
-
Method Details
-
formatTransferDebugMessage
public static String formatTransferDebugMessage(String url, int statusCode, String reasonPhrase, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo) Format a consistent HTTP transfer debug message combining URL, status code, reason phrase and HTTP proxy server info.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 notUNKNOWN_STATUS_CODE
. Proxy information will only be included if not null.- Parameters:
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 used- Returns:
- a formatted debug message combining the parameters of this method
- Throws:
NullPointerException
- if url is null
-
formatTransferFailedMessage
public static String formatTransferFailedMessage(String url, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo) Format a consistent message for HTTP relatedTransferFailedException
.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)
withUNKNOWN_STATUS_CODE
and null reason phrase.- Parameters:
url
- the URL associated with the messageproxyInfo
- proxy server used during the transfer, may be null if none used- Returns:
- a formatted failure message combining the parameters of this method
-
formatTransferFailedMessage
public static String formatTransferFailedMessage(String url, int statusCode, String reasonPhrase, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo) Format a consistent message for HTTP relatedTransferFailedException
.- Parameters:
url
- the URL associated with the messagestatusCode
- an HTTP response status code orUNKNOWN_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 used- Returns:
- a formatted failure message combining the parameters of this method
-
formatAuthorizationMessage
public static String formatAuthorizationMessage(String url, int statusCode, String reasonPhrase, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo) Format a consistent message for HTTP relatedAuthorizationException
.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.- Parameters:
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 used- Returns:
- a consistent message for a HTTP related
AuthorizationException
-
formatResourceDoesNotExistMessage
public static String formatResourceDoesNotExistMessage(String url, int statusCode, String reasonPhrase, org.apache.maven.wagon.proxy.ProxyInfo proxyInfo) Format a consistent message for HTTP relatedResourceDoesNotExistException
.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.- Parameters:
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 used- Returns:
- a consistent message for a HTTP related
ResourceDoesNotExistException
-