本文整理匯總了Java中org.springframework.http.client.ClientHttpRequestExecution.execute方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientHttpRequestExecution.execute方法的具體用法?Java ClientHttpRequestExecution.execute怎麽用?Java ClientHttpRequestExecution.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.http.client.ClientHttpRequestExecution
的用法示例。
在下文中一共展示了ClientHttpRequestExecution.execute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
@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);
}
開發者ID:apache,項目名稱:incubator-servicecomb-saga,代碼行數:17,代碼來源:TransactionClientHttpRequestInterceptor.java
示例2: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
@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;
}
示例3: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的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);
}
示例4: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的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;
}
示例5: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
@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;
}
示例6: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
/**
* This isn't needed now - but was needed when trying to figure out why term extractor wasn't
* returning data.
*/
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
// HttpHeaders headers = request.getHeaders();
// headers.add("Accept",
// "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
/*
* headers.add("X-User-Agent",
* "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 Query String Parametersview sourceview URL encoded"
* );
* headers.add("Accept-Encoding", "gzip, deflate, sdch");
* headers.add("Accept-Language", "en-US,en;q=0.8");
* headers.add("Cache-Control", "max-age=0");
* headers.add("Connection", "keep-alive");
* headers.add("Cookie",
* "CTK=19asr9k230nph1f0; RF=\"TFTzyBUJoNr4wP5QpciSOn6ifEMTEVq4ARC0hGY5P-gkhvCY-D1UltWIqfxDhxhHqiN1UggLuPE=\"; IRF=\"1qRi-3v0F_uf-yOkOwHemehIPriDHeZ-AD_rnIAayJ8=\"; CSRF=RCTCj8Abxq9j3u0bL2cYybndr26rFwzL; LC=\"co=FR&hl=fr_FR\"; SHOE=\"uQsQNsQkFYUJ008ISZ8DRWVFtv6W_JMN4mdL-LLfXiJuOW0VoJAjjiVpkv4kQoV23Sg-_-1ytM1OqAz8ROZROJDcOAoDohJHdMU_EBqxbwMOyVIOjrryq7DH189GzMI=\"; PUB=1; BIGipServerjob_iad=!YlkJJm1KgDuhYWHnj+SL47ecq6aoxVInDdjtEnHOjpnVpzOxZBWTrFttjRp0eryuGzkmkx1TYdWHS2k=; INDEED_CSRF_TOKEN=ClPCTHOQ2zlw3egLg2bQl8WakmtEeWpf; _mkto_trk=id:699-SXJ-715&token:_mch-indeed.com-1420554563497-42566; TS01c598d3=0160a2beff09f16a3c10d0f0f0a6a553318c160463ca6c315ab349cad0aefb8dfaa95db17be5052c844f60ecad51ec7c72d952d440688e76cfdabdb3074ee99a7773918ac93d8b06d43de5f602f27582982fb39fbe34263631f197d1f19e0fb70752db8b562fd68ecd5716b3e3d26da06ac246cd6f060c5f347cb466bd53402f81a2506ff7ee638943466c4de4e47bb62d5ee23bd42ae6ba9a59c0ca38e446b40736cbc688; DCT=4; JSESSIONID=97208F039EED60B31A14EF12640B8D84.jasxB_iad-job18; TS016080f8=0160a2beff8af91efc651c51dff589379d71c19e188469c827f0265638b0194c2885f98c9fe455fc17b6ea59258cb631c44485df3e271eae4c2090e2cedce12f163b39094c07e6f01fc7144638866b7333691120a4c4648f7b3b8f00c08419b665958f61ce"
* );
* headers.add("DNT", "1");
* headers.add("Host", "api.indeed.com");
*/
return execution.execute(request, body);
}
示例7: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
throws IOException {
String urlTemplate = RestTemplateUrlTemplateHolder.getRestTemplateUrlTemplate();
if (urlTemplate == null)
urlTemplate = "none";
long startTime = registry.clock().wallTime();
String status = "CLIENT_ERROR";
try {
ClientHttpResponse response = execution.execute(request, body);
status = ((Integer) response.getRawStatusCode()).toString();
return response;
} finally {
String host = request.getURI().getHost();
registry.timer(metricName, "method", request.getMethod().name(), "uri",
urlTemplate.replaceAll("^https?://[^/]+/", "").replaceAll("/", "_").replaceAll("[{}]", "-"),
"status", status, "clientName", host != null ? host : "none").record(
registry.clock().wallTime() - startTime, TimeUnit.MILLISECONDS);
}
}
開發者ID:netflix-spring-one,項目名稱:spring-cloud-netflix-contrib,代碼行數:23,代碼來源:SpectatorClientHttpRequestInterceptor.java
示例8: createRequest
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
public LoadBalancerRequest<ClientHttpResponse> createRequest(final HttpRequest request,
final byte[] body, final ClientHttpRequestExecution execution) {
return new LoadBalancerRequest<ClientHttpResponse>() {
@Override
public ClientHttpResponse apply(final ServiceInstance instance)
throws Exception {
HttpRequest serviceRequest = new ServiceRequestWrapper(request, instance, loadBalancer);
if (transformers != null) {
for (LoadBalancerRequestTransformer transformer : transformers) {
serviceRequest = transformer.transformRequest(serviceRequest, instance);
}
}
return execution.execute(serviceRequest, body);
}
};
}
示例9: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
logger.info("Sending headers: " + request.getHeaders());
if (body.length > 0) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
HexDump.dump(body, 0, baos, 0);
logger.info("Sending to [{}]: \n{}", request.getURI(), baos.toString(Charsets.UTF_8.name()).trim());
} else {
logger.info("Sending empty body to [{}]!", request.getURI());
}
return execution.execute(request, body);
}
示例10: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
ClientHttpRequestExecution execution) throws
IOException {
HttpRequest protectedResourceRequest = new HttpRequestDecorator(request) {
@Override
public URI getURI() {
String ts = Long.toString(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()));
String hash = DigestUtils.sha1Hex(sharedSecret + ts).toLowerCase();
UriComponentsBuilder builder = UriComponentsBuilder.fromUri(super.getURI());
builder.queryParam("api_key", apiKey);
builder.queryParam("ts", ts);
builder.queryParam("hash", hash);
// all params are already encoded at this point
UriComponents uriComponents = builder.build(true);
logger.debug("requesting SlideShare API: " + uriComponents.toUriString());
return uriComponents.toUri();
}
};
return execution.execute(protectedResourceRequest, body);
}
示例11: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的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);
}
示例12: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的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);
}
示例13: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
@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;
}
示例14: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的package包/類
@Override
public ClientHttpResponse intercept(final HttpRequest httpRequest, final byte[] bytes,
final ClientHttpRequestExecution clientHttpRequestExecution) throws IOException
{
LOG.debug("################################ LoggingRequestInterceptor Start #################################");
traceRequest(httpRequest, bytes);
ClientHttpResponse response = clientHttpRequestExecution.execute(httpRequest, bytes);
traceResponse(response);
LOG.debug("################################ LoggingRequestInterceptor End ###################################");
return response;
}
示例15: intercept
import org.springframework.http.client.ClientHttpRequestExecution; //導入方法依賴的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);
}