本文整理了Java中org.springframework.http.HttpRequest.getURI()
方法的一些代码示例,展示了HttpRequest.getURI()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getURI()
方法的具体详情如下:
包路径:org.springframework.http.HttpRequest
类名称:HttpRequest
方法名:getURI
[英]Return the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).
[中]返回请求的URI(包括查询字符串(如果有的话),但仅当它的URI表示形式良好时)。
代码示例来源:origin: spring-projects/spring-framework
/**
* Return the URI of the wrapped request.
*/
@Override
public URI getURI() {
return this.request.getURI();
}
代码示例来源:origin: org.springframework/spring-web
/**
* Return the URI of the wrapped request.
*/
@Override
public URI getURI() {
return this.request.getURI();
}
代码示例来源:origin: openzipkin/brave
@Override public String url(HttpRequest request) {
return request.getURI().toString();
}
代码示例来源:origin: eugenp/tutorials
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));
}
代码示例来源:origin: javamelody/javamelody
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();
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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());
}
代码示例来源:origin: spring-projects/spring-framework
URI uri = request.getURI();
scheme = uri.getScheme();
host = uri.getHost();
代码示例来源:origin: org.springframework/spring-web
/**
* 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());
}
代码示例来源:origin: spring-projects/spring-framework
@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();
}
}
}
代码示例来源:origin: stagemonitor/stagemonitor
@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();
}
}
代码示例来源:origin: spring-projects/spring-framework
@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();
}
}
}
代码示例来源:origin: org.springframework/spring-web
URI uri = request.getURI();
scheme = uri.getScheme();
host = uri.getHost();
代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba
@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());
代码示例来源:origin: org.springframework/spring-web
@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();
}
}
}
代码示例来源:origin: liuyangming/ByteTCC
String path = httpRequest.getURI().getPath();
int position = path.startsWith("/") ? path.indexOf("/", 1) : -1;
String pathWithoutContextPath = position > 0 ? path.substring(position) : null;
代码示例来源:origin: liuyangming/ByteTCC
request.setTransactionContext(transactionContext);
String targetHost = httpRequest.getURI().getHost();
int targetPort = httpRequest.getURI().getPort();
代码示例来源:origin: org.springframework/spring-web
@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();
}
}
}
代码示例来源:origin: liuyangming/ByteTCC
(CompensableTransactionImpl) compensableManager.getCompensableTransactionQuietly();
String path = httpRequest.getURI().getPath();
int position = path.startsWith("/") ? path.indexOf("/", 1) : -1;
String pathWithoutContextPath = position > 0 ? path.substring(position) : null;
代码示例来源:origin: spring-projects/spring-framework
assertEquals(URI.create(this.server.url(path).toString()), request.getURI());
assertNotNull(request.getHeaders());
})
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
/**
* 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())));
}
内容来源于网络,如有侵权,请联系作者删除!