WebClient exposes API for access to native request
Closes gh-25115, gh-25493
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,4 +47,11 @@ public interface ClientHttpRequest extends ReactiveHttpOutputMessage {
|
||||
*/
|
||||
MultiValueMap<String, HttpCookie> getCookies();
|
||||
|
||||
/**
|
||||
* Return the request from the underlying HTTP library.
|
||||
* @param <T> the expected type of the request to cast to
|
||||
* @since 5.3
|
||||
*/
|
||||
<T> T getNativeRequest();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,6 +80,11 @@ public class ClientHttpRequestDecorator implements ClientHttpRequest {
|
||||
return this.delegate.bufferFactory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getNativeRequest() {
|
||||
return this.delegate.getNativeRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCommit(Supplier<? extends Mono<Void>> action) {
|
||||
this.delegate.beforeCommit(action);
|
||||
|
||||
@@ -94,6 +94,12 @@ class HttpComponentsClientHttpRequest extends AbstractClientHttpRequest {
|
||||
return this.dataBufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getNativeRequest() {
|
||||
return (T) this.httpRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
|
||||
return doCommit(() -> {
|
||||
|
||||
@@ -84,6 +84,12 @@ class JettyClientHttpRequest extends AbstractClientHttpRequest {
|
||||
return this.bufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getNativeRequest() {
|
||||
return (T) this.jettyRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
|
||||
return Mono.<Void>create(sink -> {
|
||||
|
||||
@@ -64,11 +64,6 @@ class ReactorClientHttpRequest extends AbstractClientHttpRequest implements Zero
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DataBufferFactory bufferFactory() {
|
||||
return this.bufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return this.httpMethod;
|
||||
@@ -79,6 +74,17 @@ class ReactorClientHttpRequest extends AbstractClientHttpRequest implements Zero
|
||||
return this.uri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataBufferFactory bufferFactory() {
|
||||
return this.bufferFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getNativeRequest() {
|
||||
return (T) this.request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
|
||||
return doCommit(() -> {
|
||||
|
||||
Reference in New Issue
Block a user