本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
});
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}