Browse Source
This commit adds the base contracts for the Web client. The "Reactive" prefixes of the previously commited contracts has been removed to match the server ones. Both the `ClientHttpRequest` and the `ServerHttpResponse` extend `ReactiveHttpOutputMessage`, which now has a `beforeCommit` method, necessary in both client and server implementations. `HttpRequestBuilder` will be used by the developers to create requests with a nice builder API. `ClientHttpRequestFactory` will provide support for many HTTP client libraries in this new client.pull/1111/head
9 changed files with 149 additions and 47 deletions
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
/** |
||||
* Core package of the client-side web support. |
||||
* Provides a {@code RestTemplate} class and various callback interfaces. |
||||
*/ |
||||
package org.springframework.http.client; |
||||
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
/* |
||||
* Copyright 2002-2016 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.http.client.reactive; |
||||
|
||||
import java.net.URI; |
||||
|
||||
import reactor.core.publisher.Mono; |
||||
|
||||
import org.springframework.http.HttpMethod; |
||||
import org.springframework.http.ReactiveHttpOutputMessage; |
||||
|
||||
/** |
||||
* Represents a reactive client-side HTTP request. |
||||
* |
||||
* @author Arjen Poutsma |
||||
* @author Brian Clozel |
||||
*/ |
||||
public interface ClientHttpRequest extends ReactiveHttpOutputMessage { |
||||
|
||||
/** |
||||
* Return the HTTP method of the request. |
||||
*/ |
||||
HttpMethod getMethod(); |
||||
|
||||
/** |
||||
* Return the URI of the request. |
||||
*/ |
||||
URI getURI(); |
||||
|
||||
/** |
||||
* Execute this request, resulting in a reactive stream of a single |
||||
* {@link org.springframework.http.client.ClientHttpResponse}. |
||||
* |
||||
* @return a {@code Mono<ClientHttpResponse>} that signals when the the response |
||||
* status and headers have been received. The response body is made available with |
||||
* a separate Publisher within the {@code ClientHttpResponse}. |
||||
*/ |
||||
Mono<ClientHttpResponse> execute(); |
||||
|
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
/* |
||||
* Copyright 2002-2016 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.http.client.reactive; |
||||
|
||||
import java.net.URI; |
||||
|
||||
import org.springframework.http.HttpHeaders; |
||||
import org.springframework.http.HttpMethod; |
||||
|
||||
/** |
||||
* Factory for {@link ClientHttpRequest} objects. |
||||
* |
||||
* @author Brian Clozel |
||||
*/ |
||||
public interface ClientHttpRequestFactory { |
||||
|
||||
/** |
||||
* Create a new {@link ClientHttpRequest} for the specified HTTP method, URI and headers |
||||
* |
||||
* @param httpMethod the HTTP method to execute |
||||
* @param uri the URI to create a request for |
||||
* @param headers the HTTP request headers |
||||
*/ |
||||
ClientHttpRequest createRequest(HttpMethod httpMethod, URI uri, HttpHeaders headers); |
||||
|
||||
} |
||||
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
/* |
||||
* Copyright 2002-2016 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.web.client; |
||||
|
||||
import org.springframework.http.client.reactive.ClientHttpRequest; |
||||
import org.springframework.http.client.reactive.ClientHttpRequestFactory; |
||||
|
||||
/** |
||||
* Build {@link ClientHttpRequest} using a {@link ClientHttpRequestFactory} |
||||
* which wraps an HTTP client implementation. |
||||
* |
||||
* @author Brian Clozel |
||||
*/ |
||||
public interface HttpRequestBuilder { |
||||
|
||||
/** |
||||
* Build a {@link ClientHttpRequest} |
||||
*/ |
||||
ClientHttpRequest build(ClientHttpRequestFactory factory); |
||||
} |
||||
Loading…
Reference in new issue