Package com.gooddata.sdk.service
Class HeaderSettingRequestInterceptor
java.lang.Object
com.gooddata.sdk.service.HeaderSettingRequestInterceptor
- All Implemented Interfaces:
org.springframework.http.client.ClientHttpRequestInterceptor
public class HeaderSettingRequestInterceptor
extends Object
implements org.springframework.http.client.ClientHttpRequestInterceptor
Intercepts client-side HTTP requests and sets HTTP headers passed to constructor of this class.
Implementations of this interface can be registered with the RestTemplate, as to modify the outgoing
ClientHttpRequest and/or the incoming ClientHttpResponse.
-
Constructor Summary
ConstructorsConstructorDescriptionHeaderSettingRequestInterceptor(Map<String, String> headers) Construct interceptor for setting given HTTP headers. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.client.ClientHttpResponseintercept(org.springframework.http.HttpRequest request, byte[] body, org.springframework.http.client.ClientHttpRequestExecution execution) Intercept the given request, set headers passed to constructor, and return a response.
-
Constructor Details
-
HeaderSettingRequestInterceptor
Construct interceptor for setting given HTTP headers.- Parameters:
headers- the map of HTTP header names to header values
-
-
Method Details
-
intercept
public org.springframework.http.client.ClientHttpResponse intercept(org.springframework.http.HttpRequest request, byte[] body, org.springframework.http.client.ClientHttpRequestExecution execution) throws IOException Intercept the given request, set headers passed to constructor, and return a response. The givenClientHttpRequestExecutionallows the interceptor to pass on the request and response to the next entity in the chain.- Specified by:
interceptin interfaceorg.springframework.http.client.ClientHttpRequestInterceptor- Parameters:
request- the request, containing method, URI, and headersbody- the body of the requestexecution- the request execution- Returns:
- the response
- Throws:
IOException- in case of I/O errors
-