List of usage examples for org.springframework.http HttpRequest getMethod
@Nullable
default HttpMethod getMethod()
From source file:cz.jirutka.spring.http.client.cache.SimpleCacheKeyGenerator.java
public String createKey(HttpRequest request) { return request.getMethod().name() + ":" + request.getURI(); }
From source file:cz.jirutka.spring.http.client.cache.CachingHttpRequestInterceptor.java
private void log(String message, HttpRequest request) { log.debug("[{} {}] {}", request.getMethod(), request.getURI(), message); }
From source file:cz.cvut.portal.kos.services.support.LogHttpRequestInterceptor.java
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { LOG.info("{} {}", request.getMethod(), request.getURI()); return execution.execute(request, body); }
From source file:com.gopivotal.cla.github.RateLimitingClientHttpRequestInterceptor.java
private String getRequestString(HttpRequest request) { return String.format("%s %s", request.getMethod(), request.getURI()); }
From source file:org.zalando.zmon.actuator.metrics.MetricsWrapper.java
public void recordBackendRoundTripMetrics(final HttpRequest request, final ClientHttpResponse response, final StopWatch stopwatch) { try {/*from w w w.j ava 2 s .co m*/ recordBackendRoundTripMetrics(request.getMethod().name(), getHost(request), response.getRawStatusCode(), stopwatch.getTotalTimeMillis()); } catch (IOException e) { logger.warn("Could not detect status for " + response); } }
From source file:cz.jirutka.spring.http.client.cache.DefaultCachingPolicy.java
public boolean isServableFromCache(HttpRequest request) { if (!isCacheableMethod(request.getMethod())) { log.trace("Request with method {} is not serveable from cache", request.getMethod()); return false; }//w ww .j a va2 s. c om CacheControl cc = parseCacheControl(request.getHeaders()); if (cc.isNoStore()) { log.trace("Request with no-store is not serveable from cache"); return false; } if (cc.isNoCache()) { log.trace("Request with no-cache is not serveable from cache"); return false; } return true; }
From source file:net.bull.javamelody.SpringRestTemplateInterceptor.java
protected String getRequestName(HttpRequest httpRequest) { String uri = httpRequest.getURI().toString(); final int index = uri.indexOf('?'); if (index != -1) { uri = uri.substring(0, index);//from w w w. j av a 2s .c om } return uri + ' ' + httpRequest.getMethod(); }
From source file:client.PerfRequestSyncInterceptor.java
@Override public ClientHttpResponse intercept(HttpRequest hr, byte[] bytes, ClientHttpRequestExecution chre) throws IOException { stopwatch.start();//from www. j a va2 s. c o m long time = System.currentTimeMillis(); ClientHttpResponse response = chre.execute(hr, bytes); stopwatch.stop(); LOG.info(hr.getMethod() + "@ uri=" + hr.getURI() + " payload(kB)= " + (bytes.length / 1024) + ", response_time=" + stopwatch.elapsedTime(TimeUnit.MILLISECONDS) + ", response_code=" + response.getStatusCode().value()); return response; }
From source file:cz.jirutka.spring.http.client.cache.DefaultCachingPolicy.java
public boolean isResponseCacheable(HttpRequest request, ClientHttpResponse response) { HttpHeaders reqHeaders = request.getHeaders(); HttpHeaders respHeaders = response.getHeaders(); if (!isCacheableMethod(request.getMethod())) { log.trace("Not cacheable: method {}", request.getMethod()); return false; }//from w w w . ja va 2s.com if (parseCacheControl(reqHeaders).isNoStore()) { log.trace("Not cacheable: request has Cache-Control: no-store"); return false; } if (sharedCache) { if (reqHeaders.getFirst("Authorization") != null) { CacheControl cc = parseCacheControl(respHeaders); if (!cc.isPublic() && cc.getSMaxAge() <= 0) { log.trace("Not cacheable: this cache is shared and request contains " + "Authorization header, but no Cache-Control: public"); return false; } } } return isResponseCacheable(response); }
From source file:cz.jirutka.spring.http.client.cache.internal.HttpResponseCacheImpl.java
public ClientHttpResponse cacheAndReturnResponse(HttpRequest request, ClientHttpResponse response, Date requestSent, Date responseReceived) throws IOException { try {//from w ww . ja va 2 s . c o m InMemoryClientHttpResponse fetchedResp = responseReader.readResponse(response); Date initialDate = expirationResolver.resolveInitialDate(fetchedResp, requestSent, responseReceived); Date expirationDate = expirationResolver.resolveExpirationDate(fetchedResp, initialDate); cache.put(toKey(request), new CacheEntry(fetchedResp, initialDate, expirationDate)); return fetchedResp; } catch (ResponseSizeLimitExceededException ex) { log.info("[{} {}] {}", request.getMethod(), request.getURI(), "actual content length exceeded the limit"); return ex.getResponse(); } }