-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRequestLoggingInterceptor.java
More file actions
33 lines (27 loc) · 1.27 KB
/
RequestLoggingInterceptor.java
File metadata and controls
33 lines (27 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package io.bosh.client;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import java.io.IOException;
import java.nio.charset.Charset;
/**
* Created by jannikheyl on 12.02.18.
*/
public class RequestLoggingInterceptor implements ClientHttpRequestInterceptor {
private final static org.slf4j.Logger log = LoggerFactory.getLogger(RequestLoggingInterceptor.class);
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
ClientHttpResponse response = execution.execute(request, body);
log.debug("request method: {}, request URI: {}, request headers: {}, request body: {}, response status code: {}, response headers: {}, response body: {}",
request.getMethod(),
request.getURI(),
request.getHeaders(),
new String(body, Charset.forName("UTF-8")),
response.getStatusCode(),
response.getHeaders(),
response.getBody());
return response;
}
}