本文整理汇总了Java中org.springframework.http.HttpRequest.getHeaders方法的典型用法代码示例。如果您正苦于以下问题:Java HttpRequest.getHeaders方法的具体用法?Java HttpRequest.getHeaders怎么用?Java HttpRequest.getHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.http.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.getHeaders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
HttpHeaders headers = request.getHeaders();
String hybrisRequestId = headers.getFirst(YaasAwareTrait.Headers.REQUEST_ID);
LOGGER.debug(CHECKING_IF_IS_PRESENT, YaasAwareTrait.Headers.REQUEST_ID, hybrisRequestId);
if (StringUtils.isEmpty(hybrisRequestId)) {
headers.set(YaasAwareTrait.Headers.REQUEST_ID, StringUtils.EMPTY);
LOGGER.debug(ADDING_UPDATING_WITH, YaasAwareTrait.Headers.REQUEST_ID, StringUtils.EMPTY);
}
String hybrisHop = headers.getFirst(YaasAwareTrait.Headers.HOP);
LOGGER.debug(CHECKING_IF_IS_PRESENT, YaasAwareTrait.Headers.HOP, hybrisHop);
String newHybrisHop = "0";
if (NumberUtils.isDigits(hybrisHop)) {
int hop = NumberUtils.toInt(hybrisHop);
hop++;
newHybrisHop = Integer.toString(hop);
}
headers.set(YaasAwareTrait.Headers.HOP, newHybrisHop);
LOGGER.debug(ADDING_UPDATING_WITH, YaasAwareTrait.Headers.HOP, newHybrisHop);
return clientHttpRequestExecution.execute(request, body);
}
示例2: verifyExpectedTracingHeaders
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
public static void verifyExpectedTracingHeaders(HttpRequest executedRequest, Span expectedSpanForHeaders) {
HttpHeaders headers = executedRequest.getHeaders();
List<String> actualTraceIdHeaderVal = headers.get(TRACE_ID);
List<String> actualSpanIdHeaderVal = headers.get(SPAN_ID);
List<String> actualSampledHeaderVal = headers.get(TRACE_SAMPLED);
List<String> actualParentSpanIdHeaderVal = headers.get(PARENT_SPAN_ID);
if (expectedSpanForHeaders == null) {
verifyExpectedTracingHeaderValue(actualTraceIdHeaderVal, null);
verifyExpectedTracingHeaderValue(actualSpanIdHeaderVal, null);
verifyExpectedTracingHeaderValue(actualSampledHeaderVal, null);
verifyExpectedTracingHeaderValue(actualParentSpanIdHeaderVal, null);
}
else {
verifyExpectedTracingHeaderValue(actualTraceIdHeaderVal, expectedSpanForHeaders.getTraceId());
verifyExpectedTracingHeaderValue(actualSpanIdHeaderVal, expectedSpanForHeaders.getSpanId());
verifyExpectedTracingHeaderValue(
actualSampledHeaderVal,
convertSampleableBooleanToExpectedB3Value(expectedSpanForHeaders.isSampleable())
);
verifyExpectedTracingHeaderValue(actualParentSpanIdHeaderVal, expectedSpanForHeaders.getParentSpanId());
}
}
示例3: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@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;
}
示例4: invokeBeforeSendRequest
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
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);
}
示例5: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@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);
}
示例6: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@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);
}
示例7: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@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);
}
示例8: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@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);
}
示例9: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes, ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
HttpHeaders headers = httpRequest.getHeaders();
for (Map.Entry<String, String> entry : HeaderPropagationHolder.entries()) {
headers.set(entry.getKey(), entry.getValue());
}
return clientHttpRequestExecution.execute(httpRequest, bytes);
}
开发者ID:saturnism,项目名称:istio-by-example-java,代码行数:9,代码来源:HeaderPropagationClientHttpRequestInterceptor.java
示例10: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(HttpRequest httpRequest, byte[] bytes,
ClientHttpRequestExecution clientHttpRequestExecution) throws IOException {
HttpHeaders headers = httpRequest.getHeaders();
headers.add(HttpHeaders.AUTHORIZATION,
encodeCredentialsForBasicAuth(username, password));
return clientHttpRequestExecution.execute(httpRequest, bytes);
}
示例11: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
final ClientHttpRequestExecution execution) throws IOException {
HttpHeaders headers = request.getHeaders();
headers.add("X-Subject-Token", currentToken);
headers.add("X-Auth-Token", currentToken);
return execution.execute(request, body);
}
示例12: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
final ClientHttpRequestExecution execution) throws IOException {
HttpHeaders headers = request.getHeaders();
headers.add("X-Auth-Token", tokenManager.getTokenHolder(userName).getUnscoped());
return execution.execute(request, body);
}
示例13: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
final ClientHttpRequestExecution execution) throws IOException {
HttpHeaders headers = request.getHeaders();
headers.add("X-Auth-Token", tokenManager.getTokenHolder().getUnscoped());
headers.add("X-Subject-Token", tokenManager.getTokenHolder().getUnscoped());
return execution.execute(request, body);
}
示例14: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
final ClientHttpRequestExecution execution) throws IOException {
HttpHeaders headers = request.getHeaders();
headers.add("X-Auth-Token", tokenManager.getTokenHolder().getUnscoped());
if (LOG.isInfoEnabled()) {
LOG.info("X-Auth-Token: " + tokenManager.getTokenHolder().getUnscoped());
}
return execution.execute(request, body);
}
示例15: intercept
import org.springframework.http.HttpRequest; //导入方法依赖的package包/类
@Override
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
final ClientHttpRequestExecution execution) throws IOException {
HttpHeaders headers = request.getHeaders();
headers.add("X-Auth-Token", tokenManager.getTokenHolder().getScopedToken(projectId));
if (LOG.isInfoEnabled()) {
LOG.info("X-Auth-Token: " + tokenManager.getTokenHolder().getScopedToken(projectId));
}
return execution.execute(request, body);
}