Deprecated ClientRequest.method in favor of ClientRequest.create
The former method clashed with the ClientRequest.method() getter.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -111,11 +111,7 @@ public interface ClientRequest {
|
||||
*/
|
||||
static Builder from(ClientRequest other) {
|
||||
Assert.notNull(other, "'other' must not be null");
|
||||
return new DefaultClientRequestBuilder(other.method(), other.url())
|
||||
.headers(headers -> headers.addAll(other.headers()))
|
||||
.cookies(cookies -> cookies.addAll(other.cookies()))
|
||||
.attributes(attributes -> attributes.putAll(other.attributes()))
|
||||
.body(other.body());
|
||||
return new DefaultClientRequestBuilder(other);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,11 +119,23 @@ public interface ClientRequest {
|
||||
* @param method the HTTP method (GET, POST, etc)
|
||||
* @param url the URL
|
||||
* @return the created builder
|
||||
* @deprecated in favor of {@link #create(HttpMethod, URI)}
|
||||
*/
|
||||
@Deprecated
|
||||
static Builder method(HttpMethod method, URI url) {
|
||||
return new DefaultClientRequestBuilder(method, url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a request builder with the given method and url.
|
||||
* @param method the HTTP method (GET, POST, etc)
|
||||
* @param url the URL
|
||||
* @return the created builder
|
||||
*/
|
||||
static Builder create(HttpMethod method, URI url) {
|
||||
return new DefaultClientRequestBuilder(method, url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines a builder for a request.
|
||||
@@ -235,8 +243,8 @@ public interface ClientRequest {
|
||||
Builder attributes(Consumer<Map<String, Object>> attributesConsumer);
|
||||
|
||||
/**
|
||||
* Builds the request entity with no body.
|
||||
* @return the request entity
|
||||
* Builds the request.
|
||||
* @return the request
|
||||
*/
|
||||
ClientRequest build();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -67,6 +67,14 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public DefaultClientRequestBuilder(ClientRequest other) {
|
||||
this(other.method(), other.url());
|
||||
headers(headers -> headers.addAll(other.headers()));
|
||||
cookies(cookies -> cookies.addAll(other.cookies()));
|
||||
attributes(attributes -> attributes.putAll(other.attributes()));
|
||||
body(other.body());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientRequest.Builder method(HttpMethod method) {
|
||||
Assert.notNull(method, "'method' must not be null");
|
||||
|
||||
@@ -324,7 +324,7 @@ class DefaultWebClient implements WebClient {
|
||||
|
||||
private ClientRequest.Builder initRequestBuilder() {
|
||||
URI uri = this.uri != null ? this.uri : uriBuilderFactory.expand("");
|
||||
return ClientRequest.method(this.httpMethod, uri)
|
||||
return ClientRequest.create(this.httpMethod, uri)
|
||||
.headers(headers -> headers.addAll(initHeaders()))
|
||||
.cookies(cookies -> cookies.addAll(initCookies()))
|
||||
.attributes(attributes -> attributes.putAll(this.attributes));
|
||||
|
||||
Reference in New Issue
Block a user