当前位置: 首页>>代码示例>>Java>>正文


Java HttpRequestWrapper类代码示例

本文整理汇总了Java中org.springframework.http.client.support.HttpRequestWrapper的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestWrapper类的具体用法?Java HttpRequestWrapper怎么用?Java HttpRequestWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpRequestWrapper类属于org.springframework.http.client.support包,在下文中一共展示了HttpRequestWrapper类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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);
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:11,代码来源:HeaderRequestInterceptor.java

示例2: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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);

}
 
开发者ID:marlonwang,项目名称:raven,代码行数:11,代码来源:AcceptHeaderHttpRequestInterceptor.java

示例3: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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);
}
 
开发者ID:spring-projects,项目名称:spring-credhub,代码行数:12,代码来源:CredHubClient.java

示例4: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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);
}
 
开发者ID:vlsidlyarevich,项目名称:unity,代码行数:9,代码来源:HeaderRequestInterceptor.java

示例5: validateRequestWhenUriStartsWithRootUriShouldReplaceUri

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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"));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:RootUriRequestExpectationManagerTests.java

示例6: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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);
}
 
开发者ID:BlackPepperSoftware,项目名称:bowman,代码行数:9,代码来源:JsonClientHttpRequestInterceptor.java

示例7: createAcceptBrotliEncodingInterceptor

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
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);
    }
  });
}
 
开发者ID:MeteoGroup,项目名称:jbrotli,代码行数:11,代码来源:HelloBrotliHttpControllerTest.java

示例8: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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);
}
 
开发者ID:trustedanalytics,项目名称:cf-client,代码行数:9,代码来源:HeaderAddingHttpInterceptor.java

示例9: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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);
}
 
开发者ID:mmmod,项目名称:LansforsakringarRestClient,代码行数:9,代码来源:LoginService.java

示例10: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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);
}
 
开发者ID:mmmod,项目名称:LansforsakringarRestClient,代码行数:10,代码来源:TokenHeaderInceptor.java

示例11: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
@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);
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:7,代码来源:RestClient.java

示例12: intercept

import org.springframework.http.client.support.HttpRequestWrapper; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:gooddata,项目名称:gooddata-java,代码行数:21,代码来源:HeaderSettingRequestInterceptor.java


注:本文中的org.springframework.http.client.support.HttpRequestWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。