Java 类org.springframework.http.client.support.HttpRequestWrapper 实例源码

项目:twitch4j    文件:HeaderRequestInterceptor.java   
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
    HttpRequestWrapper wrapper = new HttpRequestWrapper(request);

    if(name != null && value != null) {
        wrapper.getHeaders().set(name, value);
    }

    return execution.execute(wrapper, body);
}
项目:raven    文件:AcceptHeaderHttpRequestInterceptor.java   
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
        throws IOException
{
    HttpRequestWrapper requestWrapper = new HttpRequestWrapper(request);
    requestWrapper.getHeaders().setAccept(Collections.singletonList(mediaType));

    return execution.execute(requestWrapper, body);

}
项目:spring-credhub    文件:CredHubClient.java   
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
                                    ClientHttpRequestExecution execution) throws IOException {
    HttpRequestWrapper requestWrapper = new HttpRequestWrapper(request);

    HttpHeaders headers = requestWrapper.getHeaders();
    headers.setAccept(singletonList(MediaType.APPLICATION_JSON));
    headers.setContentType(MediaType.APPLICATION_JSON);

    return execution.execute(requestWrapper, body);
}
项目:unity    文件:HeaderRequestInterceptor.java   
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
                                    final ClientHttpRequestExecution execution)
        throws IOException {
    final HttpRequest wrapper = new HttpRequestWrapper(request);
    wrapper.getHeaders().set(headerName, headerValue);
    return execution.execute(wrapper, body);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:RootUriRequestExpectationManagerTests.java   
@Test
public void validateRequestWhenUriStartsWithRootUriShouldReplaceUri()
        throws Exception {
    ClientHttpRequest request = mock(ClientHttpRequest.class);
    given(request.getURI()).willReturn(new URI(this.uri + "/hello"));
    this.manager.validateRequest(request);
    verify(this.delegate).validateRequest(this.requestCaptor.capture());
    HttpRequestWrapper actual = (HttpRequestWrapper) this.requestCaptor.getValue();
    assertThat(actual.getRequest()).isSameAs(request);
    assertThat(actual.getURI()).isEqualTo(new URI("/hello"));
}
项目:bowman    文件:JsonClientHttpRequestInterceptor.java   
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
        throws IOException {
    HttpRequestWrapper wrapped = new HttpRequestWrapper(request);
    wrapped.getHeaders().put("Content-Type", asList(MediaTypes.HAL_JSON_VALUE));
    wrapped.getHeaders().put("Accept", asList(MediaTypes.HAL_JSON_VALUE));
    return execution.execute(wrapped, body);
}
项目:spring-boot-concourse    文件:RootUriRequestExpectationManagerTests.java   
@Test
public void validateRequestWhenUriStartsWithRootUriShouldReplaceUri()
        throws Exception {
    ClientHttpRequest request = mock(ClientHttpRequest.class);
    given(request.getURI()).willReturn(new URI(this.uri + "/hello"));
    this.manager.validateRequest(request);
    verify(this.delegate).validateRequest(this.requestCaptor.capture());
    HttpRequestWrapper actual = (HttpRequestWrapper) this.requestCaptor.getValue();
    assertThat(actual.getRequest()).isSameAs(request);
    assertThat(actual.getURI()).isEqualTo(new URI("/hello"));
}
项目:jbrotli    文件:HelloBrotliHttpControllerTest.java   
private static List<ClientHttpRequestInterceptor> createAcceptBrotliEncodingInterceptor() {
  return singletonList((ClientHttpRequestInterceptor) new ClientHttpRequestInterceptor() {
    @Override
    public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
      HttpRequest wrapper = new HttpRequestWrapper(request);
      wrapper.getHeaders().set("Accept-Encoding", BROTLI_HTTP_CONTENT_CODING);
      return execution.execute(wrapper, body);
    }
  });
}
项目:cf-client    文件:HeaderAddingHttpInterceptor.java   
@Override public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes,
    ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {

    HttpRequestWrapper requestWrapper = new HttpRequestWrapper(httpRequest);
    requestWrapper.getHeaders().set(headerKey, headerValue);

    return clientHttpRequestExecution.execute(requestWrapper, bytes);
}
项目:LansforsakringarRestClient    文件:LoginService.java   
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
        throws IOException {
    HttpRequestWrapper requestWrapper = new HttpRequestWrapper(request);
    requestWrapper.getHeaders().add("ctoken", ctoken);
    requestWrapper.getHeaders().add("DeviceId", "f8280cf34708c7b5a8bd2ed93dcd3c8148d00000");
    return execution.execute(requestWrapper, body);
}
项目:LansforsakringarRestClient    文件:TokenHeaderInceptor.java   
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
        throws IOException {
    HttpRequestWrapper requestWrapper = new HttpRequestWrapper(request);
    requestWrapper.getHeaders().add("ctoken", ctoken);
    requestWrapper.getHeaders().add("utoken", utoken);
    requestWrapper.getHeaders().add("DeviceId", "f8280cf34708c7b5a8bd2ed93dcd3c8148d00000");
    return execution.execute(requestWrapper, body);
}
项目:thingsboard    文件:RestClient.java   
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] bytes, ClientHttpRequestExecution execution) throws IOException {
    HttpRequest wrapper = new HttpRequestWrapper(request);
    wrapper.getHeaders().set(JWT_TOKEN_HEADER_PARAM, "Bearer " + token);
    return execution.execute(wrapper, bytes);
}
项目:gooddata-java    文件:HeaderSettingRequestInterceptor.java   
/**
 * Intercept the given request, set headers passed to constructor, and return a response.
 * The given {@link org.springframework.http.client.ClientHttpRequestExecution} allows the interceptor
 * to pass on the request and response to the next entity in the chain.
 *
 * @param request   the request, containing method, URI, and headers
 * @param body      the body of the request
 * @param execution the request execution
 * @return the response
 * @throws IOException in case of I/O errors
 */
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
                                    ClientHttpRequestExecution execution) throws IOException {
    final HttpRequestWrapper requestWrapper = new HttpRequestWrapper(request);
    for (final Map.Entry<String, String> header : headers.entrySet()) {
        requestWrapper.getHeaders().set(header.getKey(), header.getValue());
    }
    return execution.execute(requestWrapper, body);
}