Java 类org.springframework.http.HttpRequest 实例源码
项目:seldon-core
文件:SeldonRestTemplateExchangeTagsProvider.java
@Override
public Iterable<Tag> getTags(String urlTemplate, HttpRequest request, ClientHttpResponse response)
{
Tag uriTag = StringUtils.hasText(urlTemplate)? RestTemplateExchangeTags.uri(urlTemplate): RestTemplateExchangeTags.uri(request);
return Arrays.asList(RestTemplateExchangeTags.method(request), uriTag,
RestTemplateExchangeTags.status(response),
RestTemplateExchangeTags.clientName(request),
modelName(request),
modelImage(request),
modelVersion(request),
projectName(),
deploymentName(),
deploymentVersion(),
predictorName(),
predictorVersion());
}
项目:spring4-understanding
文件:AbstractMessageConverterMethodArgumentResolver.java
public EmptyBodyCheckingHttpInputMessage(HttpInputMessage inputMessage) throws IOException {
this.headers = inputMessage.getHeaders();
InputStream inputStream = inputMessage.getBody();
if (inputStream == null) {
this.body = null;
}
else if (inputStream.markSupported()) {
inputStream.mark(1);
this.body = (inputStream.read() != -1 ? inputStream : null);
inputStream.reset();
}
else {
PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
int b = pushbackInputStream.read();
if (b == -1) {
this.body = null;
}
else {
this.body = pushbackInputStream;
pushbackInputStream.unread(b);
}
}
this.method = ((HttpRequest) inputMessage).getMethod();
}
项目:spring-rest-template-logger
文件:LoggingInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException
{
if (log.isDebugEnabled())
{
log.debug(String.format("Request: %s %s %s", request.getMethod(), request.getURI(),
new String(body, getCharset(request))));
}
ClientHttpResponse response = execution.execute(request, body);
if (log.isDebugEnabled())
{
log.debug(String.format("Response: %s %s", response.getStatusCode().value(),
copyToString(response.getBody(), getCharset(response))));
}
return response;
}
项目:incubator-servicecomb-saga
文件:TransactionClientHttpRequestInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
ClientHttpRequestExecution execution) throws IOException {
if (omegaContext.globalTxId() != null) {
request.getHeaders().add(GLOBAL_TX_ID_KEY, omegaContext.globalTxId());
request.getHeaders().add(LOCAL_TX_ID_KEY, omegaContext.localTxId());
LOG.debug("Added {} {} and {} {} to request header",
GLOBAL_TX_ID_KEY,
omegaContext.globalTxId(),
LOCAL_TX_ID_KEY,
omegaContext.localTxId());
}
return execution.execute(request, body);
}
项目:teamcity-hashicorp-vault-plugin
文件:VaultTemplate.java
private RestTemplate createSessionTemplate(VaultEndpoint endpoint,
ClientHttpRequestFactory requestFactory) {
RestTemplate restTemplate = UtilKt.createRestTemplate(endpoint, requestFactory);
restTemplate.getInterceptors().add(new ClientHttpRequestInterceptor() {
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
ClientHttpRequestExecution execution) throws IOException {
final VaultToken sessionToken = sessionManager.getSessionToken();
if (sessionToken != null) {
final String token = sessionToken.getToken();
if (token != null) {
request.getHeaders().add(VaultHttpHeaders.VAULT_TOKEN, token);
}
}
return execution.execute(request, body);
}
});
return restTemplate;
}
项目:lams
文件:InterceptingClientHttpRequest.java
@Override
public ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException {
if (iterator.hasNext()) {
ClientHttpRequestInterceptor nextInterceptor = iterator.next();
return nextInterceptor.intercept(request, body, this);
}
else {
ClientHttpRequest delegate = requestFactory.createRequest(request.getURI(), request.getMethod());
delegate.getHeaders().putAll(request.getHeaders());
if (body.length > 0) {
StreamUtils.copy(body, delegate.getBody());
}
return delegate.execute();
}
}
项目:desafio-pagarme
文件:Client.java
/**
* Sets the api key.
*
* @throws JsonParseException the json parse exception
* @throws JsonMappingException the json mapping exception
* @throws IOException Signals that an I/O exception has occurred.
*/
private void setApiKey() throws JsonParseException, JsonMappingException, IOException{
ArrayList<ClientHttpRequestInterceptor> interceptors = new ArrayList<ClientHttpRequestInterceptor>();
interceptors.add((HttpRequest request, byte[] body, ClientHttpRequestExecution execution) -> {
if(body.length > 0) {
body = addTokenInObject(body, new JsonNodeFormatter());
}else{
try {
request = addTokenInURI(request);
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
return execution.execute(request, body);
});
this.restTemplate.setInterceptors(interceptors);
}
项目:AndroidSnooper
文件:SpringHttpRequestTransformerTest.java
@Test
public void shouldTransformHttpCallFromClientSideError() throws Exception {
String url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0";
URI uri = create(url);
String requestBody = "requestBody";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.put("Content-Type", Arrays.asList("application/json"));
HttpRequest httpRequest = mock(HttpRequest.class);
when(httpRequest.getMethod()).thenReturn(POST);
when(httpRequest.getURI()).thenReturn(uri);
when(httpRequest.getHeaders()).thenReturn(httpHeaders);
IOException ioException = new UnknownHostException("Unable to connect");
SpringHttpRequestTransformer transformer = new SpringHttpRequestTransformer();
HttpCall httpCall = transformer.transform(httpRequest, toBytes(requestBody), ioException);
assertThat(httpCall.getMethod(), is("POST"));
assertThat(httpCall.getPayload(), is(requestBody));
assertThat(httpCall.getUrl(), is(url));
assertThat(httpCall.getRequestHeaders().size(), is(1));
assertNotNull(httpCall.getRequestHeaders().get(CONTENT_TYPE));
assertThat(httpCall.getError(), is("java.net.UnknownHostException: Unable to connect"));
}
项目:MicroServiceDemo
文件:LoggingRequestInterceptor.java
private void log(HttpRequest request, byte[] body, ClientHttpResponse response) throws IOException {
//do logging
String from = name;
String to = request.getURI().
toString().
replace("http://", "").
replace("http:// www.", "").
replace("www.", "").
replace("/", "%20").
toLowerCase();
System.out.println(from);
System.out.println(to);
restTemplate.postForObject("http://trace-callback-service/" + from + "/" + to, null, Object.class);
}
项目:spring4-understanding
文件:ServletUriComponentsBuilder.java
/**
* Initialize a builder with a scheme, host,and port (but not path and query).
*/
private static ServletUriComponentsBuilder initFromRequest(HttpServletRequest request) {
HttpRequest httpRequest = new ServletServerHttpRequest(request);
UriComponents uriComponents = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
String scheme = uriComponents.getScheme();
String host = uriComponents.getHost();
int port = uriComponents.getPort();
ServletUriComponentsBuilder builder = new ServletUriComponentsBuilder();
builder.scheme(scheme);
builder.host(host);
if (("http".equals(scheme) && port != 80) || ("https".equals(scheme) && port != 443)) {
builder.port(port);
}
return builder;
}
项目:spring4-understanding
文件:ServletUriComponentsBuilderTests.java
@Test
public void fromRequestWithForwardedHostAndPort() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setScheme("http");
request.setServerName("localhost");
request.setServerPort(80);
request.setRequestURI("/mvc-showcase");
request.addHeader("X-Forwarded-Proto", "https");
request.addHeader("X-Forwarded-Host", "84.198.58.199");
request.addHeader("X-Forwarded-Port", "443");
HttpRequest httpRequest = new ServletServerHttpRequest(request);
UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
assertEquals("https://84.198.58.199/mvc-showcase", result.toString());
}
项目:spring4-understanding
文件:UriComponentsBuilderTests.java
@Test
public void fromHttpRequestResetsPortBeforeSettingIt() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader("X-Forwarded-Proto", "https");
request.addHeader("X-Forwarded-Host", "84.198.58.199");
request.addHeader("X-Forwarded-Port", 443);
request.setScheme("http");
request.setServerName("example.com");
request.setServerPort(80);
request.setRequestURI("/rest/mobile/users/1");
HttpRequest httpRequest = new ServletServerHttpRequest(request);
UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
assertEquals("https", result.getScheme());
assertEquals("84.198.58.199", result.getHost());
assertEquals(-1, result.getPort());
assertEquals("/rest/mobile/users/1", result.getPath());
}
项目:spring4-understanding
文件:UriComponentsBuilderTests.java
@Test
public void fromHttpRequestWithForwardedHostWithForwardedScheme() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setScheme("http");
request.setServerName("localhost");
request.setServerPort(10080);
request.addHeader("X-Forwarded-Host", "example.org");
request.addHeader("X-Forwarded-Proto", "https");
HttpRequest httpRequest = new ServletServerHttpRequest(request);
UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
assertEquals("example.org", result.getHost());
assertEquals("https", result.getScheme());
assertEquals(-1, result.getPort());
}
项目:spring4-understanding
文件:UriComponentsBuilderTests.java
@Test
public void fromHttpRequestWithForwardedProtoAndDefaultPort() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setScheme("http");
request.setServerName("localhost");
request.setServerPort(80);
request.setRequestURI("/mvc-showcase");
request.addHeader("X-Forwarded-Proto", "https");
request.addHeader("X-Forwarded-Host", "84.198.58.199");
request.addHeader("X-Forwarded-Port", "443");
HttpRequest httpRequest = new ServletServerHttpRequest(request);
UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
assertEquals("https://84.198.58.199/mvc-showcase", result.toString());
}
项目:spring4-understanding
文件:UriComponentsBuilderTests.java
@Test
public void fromHttpRequestWithForwardedProtoMultiValueHeader() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setScheme("http");
request.setServerName("localhost");
request.setServerPort(8080);
request.setRequestURI("/mvc-showcase");
request.addHeader("X-Forwarded-Host", "a.example.org");
request.addHeader("X-Forwarded-Port", "443");
request.addHeader("X-Forwarded-Proto", "https,https");
HttpRequest httpRequest = new ServletServerHttpRequest(request);
UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
assertEquals("https://a.example.org/mvc-showcase", result.toString());
}
项目:mojito
文件:FormLoginAuthenticationCsrfTokenInterceptor.java
/**
* Init
*/
@PostConstruct
protected void init() {
restTemplateForAuthenticationFlow = new CookieStoreRestTemplate();
cookieStore = restTemplateForAuthenticationFlow.getCookieStore();
logger.debug("Inject cookie store used in the rest template for authentication flow into the authRestTemplate so that they will match");
authRestTemplate.restTemplate.setCookieStoreAndUpdateRequestFactory(cookieStore);
List<ClientHttpRequestInterceptor> interceptors = Collections
.<ClientHttpRequestInterceptor>singletonList(new ClientHttpRequestInterceptor() {
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
if (latestCsrfToken != null) {
// At the beginning of auth flow, there's no token yet
injectCsrfTokenIntoHeader(request, latestCsrfToken);
}
return execution.execute(request, body);
}
});
restTemplateForAuthenticationFlow.setRequestFactory(new InterceptingClientHttpRequestFactory(restTemplateForAuthenticationFlow.getRequestFactory(), interceptors));
}
项目:uaa-service
文件:HttpHeaderInterceptor.java
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
final ClientHttpRequestExecution execution) throws IOException {
final HttpHeaders requestHeaders = request.getHeaders();
for (final Entry<String, String> entry : headers.entrySet()) {
requestHeaders.add(entry.getKey(), entry.getValue());
}
return execution.execute(request, body);
}
项目:wingtips
文件:WingtipsClientHttpRequestInterceptor.java
@Override
public ClientHttpResponse intercept(
HttpRequest request, byte[] body, ClientHttpRequestExecution execution
) throws IOException {
Tracer tracer = Tracer.getInstance();
Span spanAroundCall = null;
try {
if (surroundCallsWithSubspan) {
// Will start a new trace if necessary, or a subspan if a trace is already in progress.
spanAroundCall = tracer.startSpanInCurrentContext(getSubspanSpanName(request), SpanPurpose.CLIENT);
}
HttpRequest wrapperRequest = new HttpRequestWrapperWithModifiableHeaders(request);
propagateTracingHeaders(wrapperRequest, tracer.getCurrentSpan());
return execution.execute(wrapperRequest, body);
}
finally {
if (spanAroundCall != null) {
// Span.close() contains the logic we want - if the spanAroundCall was an overall span (new trace)
// then tracer.completeRequestSpan() will be called, otherwise it's a subspan and
// tracer.completeSubSpan() will be called.
spanAroundCall.close();
}
}
}
项目:wingtips
文件:HttpRequestWrapperWithModifiableHeadersTest.java
@Test
public void verify_non_header_wrapper_methods_pass_through_to_original_request() {
// given
doReturn(new HttpHeaders()).when(requestMock).getHeaders();
HttpRequestWrapperWithModifiableHeaders wrapper = new HttpRequestWrapperWithModifiableHeaders(requestMock);
// when
HttpRequest wrappedRequest = wrapper.getRequest();
URI wrapperUri = wrapper.getURI();
HttpMethod wrapperMethod = wrapper.getMethod();
// then
assertThat(wrappedRequest).isSameAs(requestMock);
assertThat(wrapperUri).isSameAs(uri);
assertThat(wrapperMethod).isSameAs(wrapperMethod);
verify(requestMock).getURI();
verify(requestMock).getMethod();
}
项目:Robusto
文件:ResponseTimeInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException
{
long startTime = System.currentTimeMillis();
ClientHttpResponse response = execution.execute(request, body);
long endTime = System.currentTimeMillis();
if(useDebug)
{
LOG.debug("Request for {} took {} ms", request.getURI().toString(), endTime - startTime);
}
else
{
LOG.info("Request for {} took {} ms", request.getURI().toString(), endTime - startTime);
}
return response;
}
项目:haven-platform
文件:RegistryAuthInterceptor.java
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
final ClientHttpRequestExecution execution) throws IOException {
final HttpHeaders headers = request.getHeaders();
ClientHttpResponse execute = execution.execute(request, body);
if (execute.getStatusCode() == HttpStatus.UNAUTHORIZED) {
List<String> list = execute.getHeaders().get("Www-Authenticate");
if (!CollectionUtils.isEmpty(list)) {
String tokenString = list.get(0);
RegistryAuthAdapter.AuthContext ctx = new RegistryAuthAdapter.AuthContext(headers,
HttpHeaders.readOnlyHttpHeaders(headers),
tokenString);
adapter.handle(ctx);
return execution.execute(request, body);
}
}
return execute;
}
项目:bowman
文件:JsonClientHttpRequestInterceptorTest.java
@Test
public void interceptSetsContentTypeAndAcceptHeaders() throws IOException {
HttpRequest request = mock(HttpRequest.class);
when(request.getHeaders()).thenReturn(new HttpHeaders());
ClientHttpRequestExecution execution = mock(ClientHttpRequestExecution.class);
interceptor.intercept(request, new byte[] {1}, execution);
ArgumentCaptor<HttpRequest> finalRequest = ArgumentCaptor.forClass(HttpRequest.class);
verify(execution).execute(finalRequest.capture(), aryEq(new byte[] {1}));
HttpHeaders finalHeaders = finalRequest.getValue().getHeaders();
assertThat(finalHeaders.getAccept(), contains(MediaType.valueOf("application/hal+json")));
assertThat(finalHeaders.getContentType(), is(MediaType.valueOf("application/hal+json")));
}
项目:bowman
文件:AbstractIT.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace(request.getMethod().name() + " " + request.getURI() + " : "
+ new String(body, "UTF-8"));
}
ClientHttpResponse response = execution.execute(request, body);
if (LOG.isTraceEnabled()) {
LOG.trace("response " + response.getStatusCode().value() + " : "
+ IOUtils.toString(response.getBody()));
}
return response;
}
项目:ByteTCC
文件:CompensableRequestInterceptor.java
private void invokeBeforeSendRequest(HttpRequest httpRequest, String identifier) throws IOException {
SpringCloudBeanRegistry beanRegistry = SpringCloudBeanRegistry.getInstance();
CompensableBeanFactory beanFactory = beanRegistry.getBeanFactory();
CompensableManager compensableManager = beanFactory.getCompensableManager();
TransactionInterceptor transactionInterceptor = beanFactory.getTransactionInterceptor();
CompensableTransactionImpl compensable = //
(CompensableTransactionImpl) compensableManager.getCompensableTransactionQuietly();
TransactionContext transactionContext = compensable.getTransactionContext();
byte[] reqByteArray = CommonUtils.serializeObject(transactionContext);
String reqTransactionStr = ByteUtils.byteArrayToString(reqByteArray);
HttpHeaders reqHeaders = httpRequest.getHeaders();
reqHeaders.add(HEADER_TRANCACTION_KEY, reqTransactionStr);
reqHeaders.add(HEADER_PROPAGATION_KEY, this.identifier);
TransactionRequestImpl request = new TransactionRequestImpl();
request.setTransactionContext(transactionContext);
RemoteCoordinator coordinator = beanRegistry.getConsumeCoordinator(identifier);
request.setTargetTransactionCoordinator(coordinator);
transactionInterceptor.beforeSendRequest(request);
}
项目:Settings
文件:ApiClient.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
logRequest(request, body);
ClientHttpResponse response = execution.execute(request, body);
logResponse(response);
return response;
}
项目:tx-lcn
文件:TransactionHttpRequestInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
TxTransactionLocal txTransactionLocal = TxTransactionLocal.current();
String groupId = txTransactionLocal==null?null:txTransactionLocal.getGroupId();
request.getHeaders().add("tx-group",groupId);
if (txTransactionLocal != null) {
if (txTransactionLocal.isHasCompensate()) {
request.getHeaders().add("tx-group", CompensateService.COMPENSATE_KEY);
} else {
request.getHeaders().add("tx-group",groupId);
}
}
return execution.execute(request,body);
}
项目:che-starter
文件:GitHubInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
HttpHeaders headers = request.getHeaders();
headers.add(AUTHORIZATION_HEADER, gitHubToken);
headers.add(USER_AGENT_HEADER, USER_AGENT_VALUE);
headers.setContentType(MediaType.APPLICATION_JSON);
return execution.execute(request, body);
}
项目:che-starter
文件:KeycloakInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
HttpHeaders headers = request.getHeaders();
headers.add(AUTHORIZATION_HEADER, keycloakToken);
headers.add(REQUEST_ID_HEADER, getRequestId());
return execution.execute(request, body);
}
项目:java-spring-web
文件:RestTemplateSpanDecorator.java
@Override
public void onRequest(HttpRequest request, BaseSpan<?> span) {
Tags.COMPONENT.set(span, COMPONENT_NAME);
// this can be sometimes only path e.g. "/foo"
Tags.HTTP_URL.set(span, request.getURI().toString());
Tags.HTTP_METHOD.set(span, request.getMethod().toString());
if (request.getURI().getPort() != -1) {
Tags.PEER_PORT.set(span, request.getURI().getPort());
}
}
项目:java-spring-web
文件:RestTemplateSpanDecorator.java
@Override
public void onResponse(HttpRequest httpRequest, ClientHttpResponse response, BaseSpan<?> span) {
try {
Tags.HTTP_STATUS.set(span, response.getRawStatusCode());
} catch (IOException e) {
log.error("Could not get HTTP status code");
}
}
项目:teamcity-hashicorp-vault-plugin
文件:VaultTemplate.java
private VaultTemplate(VaultTemplate origin, final String wrapTTL) {
this(origin.endpoint, origin.requestFactory, origin.sessionManager);
final ClientHttpRequestInterceptor interceptor = new ClientHttpRequestInterceptor() {
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
request.getHeaders().add("X-Vault-Wrap-TTL", wrapTTL);
return execution.execute(request, body);
}
};
plainTemplate.getInterceptors().add(interceptor);
sessionTemplate.getInterceptors().add(interceptor);
}
项目:micrometer
文件:MetricsClientHttpRequestInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
ClientHttpRequestExecution execution) throws IOException {
long startTime = System.nanoTime();
ClientHttpResponse response = null;
try {
response = execution.execute(request, body);
return response;
} finally {
getTimeBuilder(request, response).register(this.meterRegistry)
.record(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
urlTemplate.remove();
}
}
项目:micrometer
文件:DefaultRestTemplateExchangeTagsProvider.java
@Override
public Iterable<Tag> getTags(String urlTemplate, HttpRequest request,
ClientHttpResponse response) {
Tag uriTag = StringUtils.hasText(urlTemplate)
? RestTemplateExchangeTags.uri(urlTemplate)
: RestTemplateExchangeTags.uri(request);
return Arrays.asList(RestTemplateExchangeTags.method(request), uriTag,
RestTemplateExchangeTags.status(response),
RestTemplateExchangeTags.clientName(request));
}
项目:micrometer
文件:RestTemplateExchangeTags.java
/**
* Create a {@code clientName} {@code Tag} derived from the {@link URI#getHost host}
* of the {@link HttpRequest#getURI() URI} of the given {@code request}.
*
* @param request the request
* @return the clientName tag
*/
public static Tag clientName(HttpRequest request) {
String host = request.getURI().getHost();
if (host == null) {
host = "none";
}
return Tag.of("clientName", host);
}
项目:OAuth-2.0-Cookbook
文件:HttpRequestWithPoPSignatureInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
ClientHttpRequestExecution execution) throws IOException {
OAuth2ClientContext clientContext = applicationContext.getBean(OAuth2ClientContext.class);
OAuth2AccessToken accessToken = clientContext.getAccessToken();
request.getHeaders().set("Authorization", "Bearer " + accessToken.getValue());
request.getHeaders().set("nonce", keyPairManager.getSignedContent(UUID.randomUUID().toString()));
return execution.execute(request, body);
}
项目: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);
}
项目:twitch4j
文件:QueryRequestInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
HttpRequestDecorator httpRequest = new HttpRequestDecorator(request);
if(name != null && value != null) {
httpRequest.addParameter(name, value);
}
return execution.execute(httpRequest, body);
}
项目:logistimo-web-service
文件:LocaleRequestInterceptor.java
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body,
ClientHttpRequestExecution execution) throws
IOException {
SecureUserDetails
userDetails =
ThreadLocalUtil.get().getSecureUserDetails();
if (userDetails != null) {
request.getHeaders().set("Accept-Language", userDetails.getLocale().getLanguage());
}
return execution.execute(request, body);
}
项目:sample.microservices.security.jwt
文件:JWTAuthenticationInterceptor.java
@Override
public ClientHttpResponse intercept(
HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
HttpHeaders headers = request.getHeaders();
headers.add("jwt", getJwt());
return execution.execute(request, body);
}