diff --git a/org.springframework.web/src/main/java/org/springframework/web/client/RestOperations.java b/org.springframework.web/src/main/java/org/springframework/web/client/RestOperations.java index e0722e63a2e..a5d14bd9f5a 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/client/RestOperations.java +++ b/org.springframework.web/src/main/java/org/springframework/web/client/RestOperations.java @@ -17,7 +17,6 @@ package org.springframework.web.client; import java.net.URI; -import java.util.EnumSet; import java.util.Map; import java.util.Set; @@ -40,24 +39,22 @@ public interface RestOperations { /** * Retrieve a representation by doing a GET on the specified URL. *
URI Template variables are expanded using the given URI variables, if any.
- * @param uri the URI
+ * @param uri the URI
* @param responseType the type of the return value
* @param uriVariables the variables to expand the template
* @return the converted object
*/
- URI Template variables are expanded using the given map.
- * @param uri the URI
+ * @param uri the URI
* @param responseType the type of the return value
* @param uriVariables the map containing variables for the URI template
* @return the converted object
*/
- URI Template variables are expanded using the given URI variables, if any.
- * @param uri the URI
+ * @param uri the URI
* @param uriVariables the variables to expand the template
* @return all HTTP headers of that resource
*/
@@ -74,7 +71,7 @@ public interface RestOperations {
/**
* Retrieve all headers of the resource specified by the URI template.
* URI Template variables are expanded using the given map.
- * @param uri the URI
+ * @param uri the URI
* @param uriVariables the map containing variables for the URI template
* @return all HTTP headers of that resource
*/
@@ -84,27 +81,25 @@ public interface RestOperations {
// POST
/**
- * Create a new resource by POSTing the given object to the URI template. The value of the URI Template variables are expanded using the given URI variables, if any.
- * @param uri the URI
- * @param request the Object to be POSTED
+ * @param uri the URI
+ * @param request the Object to be POSTed, may be URI Template variables are expanded using the given map.
- * @param uri the URI
- * @param request the Object to be POSTed
+ * @param uri the URI
+ * @param request the Object to be POSTed, may be URI Template variables are expanded using the given URI variables, if any.
- * @param uri the URI
- * @param request the Object to be POSTed
+ * @param uri the URI
+ * @param request the Object to be PUT, may be URI Template variables are expanded using the given map.
- * @param uri the URI
- * @param request the Object to be POSTed
+ * @param uri the URI
+ * @param request the Object to be PUT, may be URI Template variables are expanded using the given URI variables, if any.
- * @param uri the URI
+ * @param uri the URI
* @param uriVariables the variables to expand in the template
*/
void delete(String uri, String... uriVariables) throws RestClientException;
@@ -141,7 +136,7 @@ public interface RestOperations {
/**
* Delete the resources at the specified URI.
* URI Template variables are expanded using the given map.
- * @param uri the URI
+ * @param uri the URI
* @param uriVariables the variables to expand the template
*/
void delete(String uri, Map URI Template variables are expanded using the given URI variables, if any.
- * @param uri the URI
+ * @param uri the URI
* @param uriVariables the variables to expand in the template
* @return the value of the allow header
*/
- Set URI Template variables are expanded using the given map.
- * @param uri the URI
+ * @param uri the URI
* @param uriVariables the variables to expand in the template
* @return the value of the allow header
*/
- Set URI Template variables are expanded using the given URI variables, if any.
- * @param uri the URI
- * @param method the HTTP method (GET, POST, etc)
- * @param requestCallback object that prepares the request
+ * @param uri the URI
+ * @param method the HTTP method (GET, POST, etc)
+ * @param requestCallback object that prepares the request
* @param responseExtractor object that extracts the return value from the response
- * @param uriVariables the variables to expand in the template
+ * @param uriVariables the variables to expand in the template
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
*/
- URI Template variables are expanded using the given URI variables map.
- * @param uri the URI
- * @param method the HTTP method (GET, POST, etc)
- * @param requestCallback object that prepares the request
+ * @param uri the URI
+ * @param method the HTTP method (GET, POST, etc)
+ * @param requestCallback object that prepares the request
* @param responseExtractor object that extracts the return value from the response
- * @param uriVariablesthe variables to expand in the template
+ * @param uriVariables the variables to expand in the template
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
*/
- Location,
- * indicating where the new resource is stored, is returned.
+ * Create a new resource by POSTing the given object to the URI template. The value of the Location
+ * header, indicating where the new resource is stored, is returned.
* null
* @return the value for the Location header
*/
- URI postForLocation(String uri, Object request, String... uriVariables)
- throws RestClientException;
+ URI postForLocation(String uri, Object request, String... uriVariables) throws RestClientException;
/**
- * Create a new resource by POSTing the given object to URI template. The value of the Location,
+ * Create a new resource by POSTing the given object to URI template. The value of the Location header,
* indicating where the new resource is stored, is returned.
* null
* @param uriVariables the variables to expand the template
* @return the value for the Location header
*/
- URI postForLocation(String uri, Object request, Mapnull
* @param uriVariables the variables to expand the template
*/
void put(String uri, Object request, String... uriVariables) throws RestClientException;
@@ -121,8 +116,8 @@ public interface RestOperations {
/**
* Creates a new resource by PUTting the given object to URI template.
* null
* @param uriVariables the variables to expand the template
*/
void put(String uri, Object request, Mapnull)
+ * @param url the fully-expanded URL to connect to
+ * @param method the HTTP method to execute (GET, POST, etc.)
+ * @param requestCallback object that prepares the request (can be null)
* @param responseExtractor object that extracts the return value from the response (can be null)
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
*/
- protected T.
diff --git a/org.springframework.web/src/test/java/org/springframework/web/client/RestTemplateTests.java b/org.springframework.web/src/test/java/org/springframework/web/client/RestTemplateTests.java
index 06ed125d9b4..813d932eee7 100644
--- a/org.springframework.web/src/test/java/org/springframework/web/client/RestTemplateTests.java
+++ b/org.springframework.web/src/test/java/org/springframework/web/client/RestTemplateTests.java
@@ -263,6 +263,24 @@ public class RestTemplateTests {
verifyMocks();
}
+ @Test
+ public void postNull() throws Exception {
+ expect(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.POST)).andReturn(request);
+ HttpHeaders requestHeaders = new HttpHeaders();
+ expect(request.getHeaders()).andReturn(requestHeaders);
+ expect(request.execute()).andReturn(response);
+ expect(errorHandler.hasError(response)).andReturn(false);
+ HttpHeaders responseHeaders = new HttpHeaders();
+ expect(response.getHeaders()).andReturn(responseHeaders);
+ response.close();
+
+ replayMocks();
+ template.postForLocation("http://example.com", null);
+ assertEquals("Invalid content length", 0, requestHeaders.getContentLength());
+
+ verifyMocks();
+ }
+
@Test
public void put() throws Exception {
expect(converter.supports(String.class)).andReturn(true).times(2);
@@ -280,6 +298,22 @@ public class RestTemplateTests {
verifyMocks();
}
+ @Test
+ public void putNull() throws Exception {
+ expect(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.PUT)).andReturn(request);
+ HttpHeaders requestHeaders = new HttpHeaders();
+ expect(request.getHeaders()).andReturn(requestHeaders);
+ expect(request.execute()).andReturn(response);
+ expect(errorHandler.hasError(response)).andReturn(false);
+ response.close();
+
+ replayMocks();
+ template.put("http://example.com", null);
+ assertEquals("Invalid content length", 0, requestHeaders.getContentLength());
+
+ verifyMocks();
+ }
+
@Test
public void delete() throws Exception {
expect(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.DELETE)).andReturn(request);