/** * Return the URI of the wrapped request. */ @Override public URI getURI() { return this.request.getURI(); }
/** * Return the URI of the wrapped request. */ @Override public URI getURI() { return this.request.getURI(); }
@Override public String url(HttpRequest request) { return request.getURI().toString(); }
private void logRequest(HttpRequest request, byte[] body) throws UnsupportedEncodingException { log.info("URI: " + request.getURI()); log.info("HTTP Method: " + request.getMethod()); log.info("HTTP Headers: " + headersToString(request.getHeaders())); log.info("Request Body: " + new String(body, StandardCharsets.UTF_8)); }
protected String getRequestName(HttpRequest httpRequest) { String uri = httpRequest.getURI().toString(); final int index = uri.indexOf('?'); if (index != -1) { uri = uri.substring(0, index); } return uri + ' ' + httpRequest.getMethod(); } }
/** * Create a new {@code UriComponents} object from the URI associated with * the given HttpRequest while also overlaying with values from the headers * "Forwarded" (<a href="http://tools.ietf.org/html/rfc7239">RFC 7239</a>), * or "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" if * "Forwarded" is not found. * @param request the source request * @return the URI components of the URI * @since 4.1.5 */ public static UriComponentsBuilder fromHttpRequest(HttpRequest request) { return fromUri(request.getURI()).adaptFromForwardedHeaders(request.getHeaders()); }
URI uri = request.getURI(); scheme = uri.getScheme(); host = uri.getHost();
/** * Create a new {@code UriComponents} object from the URI associated with * the given HttpRequest while also overlaying with values from the headers * "Forwarded" (<a href="http://tools.ietf.org/html/rfc7239">RFC 7239</a>), * or "X-Forwarded-Host", "X-Forwarded-Port", and "X-Forwarded-Proto" if * "Forwarded" is not found. * @param request the source request * @return the URI components of the URI * @since 4.1.5 */ public static UriComponentsBuilder fromHttpRequest(HttpRequest request) { return fromUri(request.getURI()).adaptFromForwardedHeaders(request.getHeaders()); }
@Override public ListenableFuture<ClientHttpResponse> executeAsync(HttpRequest request, byte[] body) throws IOException { if (this.iterator.hasNext()) { AsyncClientHttpRequestInterceptor interceptor = this.iterator.next(); return interceptor.intercept(request, body, this); } else { URI uri = request.getURI(); HttpMethod method = request.getMethod(); HttpHeaders headers = request.getHeaders(); Assert.state(method != null, "No standard HTTP method"); AsyncClientHttpRequest delegate = requestFactory.createAsyncRequest(uri, method); delegate.getHeaders().putAll(headers); if (body.length > 0) { StreamUtils.copy(body, delegate.getBody()); } return delegate.executeAsync(); } } }
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { final Scope scope = new ExternalHttpRequest(tracingPlugin.getTracer(), request.getMethod().toString(), removeQuery(request.getURI()), request.getURI().getHost(), request.getURI().getPort()).createScope(); try { Profiler.start(request.getMethod().toString() + " " + request.getURI() + " "); tracingPlugin.getTracer().inject(scope.span().context(), Format.Builtin.HTTP_HEADERS, new SpringHttpRequestInjectAdapter(request)); return execution.execute(request, body); } finally { Profiler.stop(); scope.close(); } }
@Override public ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException { if (this.iterator.hasNext()) { ClientHttpRequestInterceptor nextInterceptor = this.iterator.next(); return nextInterceptor.intercept(request, body, this); } else { HttpMethod method = request.getMethod(); Assert.state(method != null, "No standard HTTP method"); ClientHttpRequest delegate = requestFactory.createRequest(request.getURI(), method); request.getHeaders().forEach((key, value) -> delegate.getHeaders().addAll(key, value)); if (body.length > 0) { if (delegate instanceof StreamingHttpOutputMessage) { StreamingHttpOutputMessage streamingOutputMessage = (StreamingHttpOutputMessage) delegate; streamingOutputMessage.setBody(outputStream -> StreamUtils.copy(body, outputStream)); } else { StreamUtils.copy(body, delegate.getBody()); } } return delegate.execute(); } } }
URI uri = request.getURI(); scheme = uri.getScheme(); host = uri.getHost();
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { URI uri = request.getURI(); String hostResource = uri.getScheme() + "://" + uri.getHost() + (uri.getPort() == -1 ? "" : ":" + uri.getPort());
@Override public ListenableFuture<ClientHttpResponse> executeAsync(HttpRequest request, byte[] body) throws IOException { if (this.iterator.hasNext()) { AsyncClientHttpRequestInterceptor interceptor = this.iterator.next(); return interceptor.intercept(request, body, this); } else { URI uri = request.getURI(); HttpMethod method = request.getMethod(); HttpHeaders headers = request.getHeaders(); Assert.state(method != null, "No standard HTTP method"); AsyncClientHttpRequest delegate = requestFactory.createAsyncRequest(uri, method); delegate.getHeaders().putAll(headers); if (body.length > 0) { StreamUtils.copy(body, delegate.getBody()); } return delegate.executeAsync(); } } }
String path = httpRequest.getURI().getPath(); int position = path.startsWith("/") ? path.indexOf("/", 1) : -1; String pathWithoutContextPath = position > 0 ? path.substring(position) : null;
@Override public ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException { if (this.iterator.hasNext()) { ClientHttpRequestInterceptor nextInterceptor = this.iterator.next(); return nextInterceptor.intercept(request, body, this); } else { HttpMethod method = request.getMethod(); Assert.state(method != null, "No standard HTTP method"); ClientHttpRequest delegate = requestFactory.createRequest(request.getURI(), method); request.getHeaders().forEach((key, value) -> delegate.getHeaders().addAll(key, value)); if (body.length > 0) { if (delegate instanceof StreamingHttpOutputMessage) { StreamingHttpOutputMessage streamingOutputMessage = (StreamingHttpOutputMessage) delegate; streamingOutputMessage.setBody(outputStream -> StreamUtils.copy(body, outputStream)); } else { StreamUtils.copy(body, delegate.getBody()); } } return delegate.execute(); } } }
(CompensableTransactionImpl) compensableManager.getCompensableTransactionQuietly(); String path = httpRequest.getURI().getPath(); int position = path.startsWith("/") ? path.indexOf("/", 1) : -1; String pathWithoutContextPath = position > 0 ? path.substring(position) : null;
assertEquals(URI.create(this.server.url(path).toString()), request.getURI()); assertNotNull(request.getHeaders()); })
/** * Creates a {@code uri} {@code Tag} for the URI of the given {@code request}. * @param request the request * @return the uri tag */ public static Tag uri(HttpRequest request) { return Tag.of("uri", ensureLeadingSlash(stripUri(request.getURI().toString()))); }