本文整理了Java中org.springframework.http.HttpRequest.getMethod()
方法的一些代码示例,展示了HttpRequest.getMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getMethod()
方法的具体详情如下:
包路径:org.springframework.http.HttpRequest
类名称:HttpRequest
方法名:getMethod
[英]Return the HTTP method of the request.
[中]返回请求的HTTP方法。
代码示例来源:origin: spring-projects/spring-framework
/**
* Return the method of the wrapped request.
*/
@Override
@Nullable
public HttpMethod getMethod() {
return this.request.getMethod();
}
代码示例来源:origin: org.springframework/spring-web
/**
* Return the method of the wrapped request.
*/
@Override
@Nullable
public HttpMethod getMethod() {
return this.request.getMethod();
}
代码示例来源: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: openzipkin/brave
@Override public String method(HttpRequest request) {
return request.getMethod().name();
}
代码示例来源: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: 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
@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: 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: 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
HttpMethod httpMethod = (inputMessage instanceof HttpRequest ? ((HttpRequest) inputMessage).getMethod() : null);
Object body = NO_VALUE;
代码示例来源:origin: org.springframework/spring-webmvc
HttpMethod httpMethod = (inputMessage instanceof HttpRequest ? ((HttpRequest) inputMessage).getMethod() : null);
Object body = NO_VALUE;
代码示例来源:origin: spring-projects/spring-integration
/**
* Checks if the request has a readable body (not a GET, HEAD, or OPTIONS request).
* @param request the HTTP request to check the method
* @return true or false if HTTP request can contain the body
*/
protected boolean isReadable(HttpRequest request) {
HttpMethod method = request.getMethod();
return method == null ? false : !(CollectionUtils.containsInstance(nonReadableBodyHttpMethods, method));
}
代码示例来源:origin: spring-projects/spring-framework
assertEquals(HttpMethod.GET, request.getMethod());
assertEquals(URI.create(this.server.url(path).toString()), request.getURI());
assertNotNull(request.getHeaders());
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
/**
* Creates a {@code method} {@code Tag} for the {@link HttpRequest#getMethod() method}
* of the given {@code request}.
* @param request the request
* @return the method tag
*/
public static Tag method(HttpRequest request) {
return Tag.of("method", request.getMethod().name());
}
代码示例来源:origin: org.springframework.integration/spring-integration-http
/**
* Checks if the request has a readable body (not a GET, HEAD, or OPTIONS request).
* @param request the HTTP request to check the method
* @return true or false if HTTP request can contain the body
*/
protected boolean isReadable(HttpRequest request) {
HttpMethod method = request.getMethod();
return method == null ? false : !(CollectionUtils.containsInstance(nonReadableBodyHttpMethods, method));
}
代码示例来源:origin: com.nike.wingtips/wingtips-spring
@Override
public @Nullable String getRequestHttpMethod(@Nullable HttpRequest request) {
if (request == null) {
return null;
}
HttpMethod method = request.getMethod();
return (method == null) ? "UNKNOWN_HTTP_METHOD" : method.name();
}
代码示例来源:origin: Evolveum/midpoint
private void logRequest(long number, HttpRequest request, byte[] body) throws IOException {
StringBuilder builder = new StringBuilder();
builder.append("ID: ").append(number).append('\n');
builder.append("Request: ").append(request.getMethod()).append(' ').append(request.getURI()).append('\n');
builder.append("Headers: ").append(request.getHeaders()).append('\n');
builder.append("Payload: ").append(getRequestBody(body));
LOG.debug("Outbound message\n---------------------\n{}\n---------------------", builder.toString());
}
代码示例来源:origin: io.micrometer/micrometer-spring-legacy
/**
* Creates a {@code method} {@code Tag} for the {@link HttpRequest#getMethod() method}
* of the given {@code request}.
*
* @param request the request
* @return the method tag
*/
public static Tag method(HttpRequest request) {
return Tag.of("method", request.getMethod().name());
}
代码示例来源:origin: aillamsun/devX
@Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
DevxTraceLogWrap.request("RestTemplate", request.getMethod().name(), request.getURI().toURL().toString());
ClientHttpResponse response = execution.execute(request, body);
DevxTraceLogWrap.response("RestTemplate", response.getRawStatusCode(), request.getMethod().name(), request.getURI().toURL().toString());
return response;
}
内容来源于网络,如有侵权,请联系作者删除!