public class HttpRequestResponseLogUtil
extends java.lang.Object
The utility can be used to generate HTTP request / response log strings. Both for incoming service calls as outgoing calls (i.e. calls to backend systems).
Constructor and Description |
---|
HttpRequestResponseLogUtil() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
createLogString(org.springframework.http.HttpHeaders headers,
byte[] body)
Create a log string for the given
headers and body with the platform's default charset. |
java.lang.String |
createLogString(org.springframework.http.HttpHeaders headers,
byte[] body,
java.nio.charset.Charset charset)
Create a log string for the given
headers and body with the given charset . |
java.lang.String |
createLogString(org.springframework.http.HttpHeaders headers,
byte[] body,
java.lang.String characterEncoding)
Create a log string for the given
headers and body with the given characterEncoding . |
java.lang.String |
createLogString(org.springframework.http.HttpHeaders headers,
java.lang.String body)
Create a log string for the given
headers and body with the platform's default charset. |
java.lang.String |
createLogString(java.lang.String requestLine,
org.springframework.http.HttpHeaders headers,
byte[] body,
java.nio.charset.Charset charset)
Create a log string for the given
requestLine , headers and body . |
java.lang.String |
createLogString(java.lang.String requestLine,
org.springframework.http.HttpHeaders headers,
byte[] body,
java.lang.String characterEncoding)
Create a log string for the given
requestLine , headers and body . |
java.lang.String |
createLogString(java.lang.String requestLine,
org.springframework.http.HttpHeaders headers,
java.lang.String body)
Create a log string for the given
requestLine , headers and body . |
java.lang.String |
createRequestLine(java.lang.String request,
java.lang.String protocol)
Create a request line for the
requestUri and protocol . |
java.lang.String |
formatRequest(java.lang.String request,
javax.servlet.http.HttpServletRequest servletRequest)
Format the request as a nicely formatted string.
|
org.springframework.http.HttpHeaders |
getHeaders(javax.servlet.http.HttpServletRequest request)
Create
HttpHeaders for the request . |
org.springframework.http.HttpHeaders |
getHeaders(javax.servlet.http.HttpServletResponse response)
Create
HttpHeaders for the response . |
java.lang.String |
getRequestUri(javax.servlet.http.HttpServletRequest servletRequest)
Transform the request into a log line.
|
public org.springframework.http.HttpHeaders getHeaders(javax.servlet.http.HttpServletRequest request)
HttpHeaders
for the request
.public org.springframework.http.HttpHeaders getHeaders(javax.servlet.http.HttpServletResponse response)
HttpHeaders
for the response
.public java.lang.String createRequestLine(java.lang.String request, java.lang.String protocol)
requestUri
and protocol
.
For example: GET /doc/test.html HTTP/1.1
.
public java.lang.String createLogString(org.springframework.http.HttpHeaders headers, java.lang.String body)
headers
and body
with the platform's default charset.public java.lang.String createLogString(org.springframework.http.HttpHeaders headers, byte[] body)
headers
and body
with the platform's default charset.public java.lang.String createLogString(org.springframework.http.HttpHeaders headers, byte[] body, java.lang.String characterEncoding)
headers
and body
with the given characterEncoding
.public java.lang.String createLogString(org.springframework.http.HttpHeaders headers, byte[] body, java.nio.charset.Charset charset)
headers
and body
with the given charset
.public java.lang.String createLogString(java.lang.String requestLine, org.springframework.http.HttpHeaders headers, byte[] body, java.lang.String characterEncoding)
requestLine
, headers
and body
.public java.lang.String createLogString(java.lang.String requestLine, org.springframework.http.HttpHeaders headers, byte[] body, java.nio.charset.Charset charset)
requestLine
, headers
and body
.public java.lang.String createLogString(java.lang.String requestLine, org.springframework.http.HttpHeaders headers, java.lang.String body)
requestLine
, headers
and body
.public java.lang.String getRequestUri(javax.servlet.http.HttpServletRequest servletRequest)
public java.lang.String formatRequest(java.lang.String request, javax.servlet.http.HttpServletRequest servletRequest) throws java.io.IOException
Note that this will read the request! Use ResettableHttpServletRequest
for instance
to reset the input.
java.io.IOException