|
|
|
@ -401,8 +401,6 @@ class DefaultWebClient implements WebClient {
@@ -401,8 +401,6 @@ class DefaultWebClient implements WebClient {
|
|
|
|
|
return new HttpRequest() { |
|
|
|
|
private final URI uri = initUri(); |
|
|
|
|
|
|
|
|
|
private final HttpHeaders headers = initHeaders(); |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public HttpMethod getMethod() { |
|
|
|
|
return httpMethod; |
|
|
|
@ -415,7 +413,9 @@ class DefaultWebClient implements WebClient {
@@ -415,7 +413,9 @@ class DefaultWebClient implements WebClient {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public HttpHeaders getHeaders() { |
|
|
|
|
return this.headers; |
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
initHeaders(headers); |
|
|
|
|
return headers; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
@ -488,8 +488,8 @@ class DefaultWebClient implements WebClient {
@@ -488,8 +488,8 @@ class DefaultWebClient implements WebClient {
|
|
|
|
|
defaultRequest.accept(this); |
|
|
|
|
} |
|
|
|
|
ClientRequest.Builder builder = ClientRequest.create(this.httpMethod, initUri()) |
|
|
|
|
.headers(headers -> headers.addAll(initHeaders())) |
|
|
|
|
.cookies(cookies -> cookies.addAll(initCookies())) |
|
|
|
|
.headers(this::initHeaders) |
|
|
|
|
.cookies(this::initCookies) |
|
|
|
|
.attributes(attributes -> attributes.putAll(this.attributes)); |
|
|
|
|
if (this.httpRequestConsumer != null) { |
|
|
|
|
builder.httpRequest(this.httpRequestConsumer); |
|
|
|
@ -501,33 +501,21 @@ class DefaultWebClient implements WebClient {
@@ -501,33 +501,21 @@ class DefaultWebClient implements WebClient {
|
|
|
|
|
return (this.uri != null ? this.uri : uriBuilderFactory.expand("")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private HttpHeaders initHeaders() { |
|
|
|
|
if (CollectionUtils.isEmpty(this.headers)) { |
|
|
|
|
return (defaultHeaders != null ? defaultHeaders : new HttpHeaders()); |
|
|
|
|
} |
|
|
|
|
else if (CollectionUtils.isEmpty(defaultHeaders)) { |
|
|
|
|
return this.headers; |
|
|
|
|
private void initHeaders(HttpHeaders out) { |
|
|
|
|
if (!CollectionUtils.isEmpty(defaultHeaders)) { |
|
|
|
|
out.putAll(defaultHeaders); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
HttpHeaders result = new HttpHeaders(); |
|
|
|
|
result.putAll(defaultHeaders); |
|
|
|
|
result.putAll(this.headers); |
|
|
|
|
return result; |
|
|
|
|
if (!CollectionUtils.isEmpty(this.headers)) { |
|
|
|
|
out.putAll(this.headers); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private MultiValueMap<String, String> initCookies() { |
|
|
|
|
if (CollectionUtils.isEmpty(this.cookies)) { |
|
|
|
|
return (defaultCookies != null ? defaultCookies : new LinkedMultiValueMap<>()); |
|
|
|
|
} |
|
|
|
|
else if (CollectionUtils.isEmpty(defaultCookies)) { |
|
|
|
|
return this.cookies; |
|
|
|
|
private void initCookies(MultiValueMap<String, String> out) { |
|
|
|
|
if (!CollectionUtils.isEmpty(defaultCookies)) { |
|
|
|
|
out.putAll(defaultCookies); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
MultiValueMap<String, String> result = new LinkedMultiValueMap<>(); |
|
|
|
|
result.putAll(defaultCookies); |
|
|
|
|
result.putAll(this.cookies); |
|
|
|
|
return result; |
|
|
|
|
if (!CollectionUtils.isEmpty(this.cookies)) { |
|
|
|
|
out.putAll(this.cookies); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|