Fixed problem when headers were written after ClientHttpRequest.execute()

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@666 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Arjen Poutsma
2009-02-22 14:35:28 +00:00
parent 975fb59d4b
commit b859ccd70e
4 changed files with 109 additions and 66 deletions
@@ -99,6 +99,25 @@ public abstract class AbstractHttpRequestFactoryTestCase {
assertTrue("Invalid body", Arrays.equals(body, result));
}
@Test(expected = IllegalStateException.class)
public void multipleWrites() throws Exception {
ClientHttpRequest request = factory.createRequest(new URI("http://localhost:8889/echo"), HttpMethod.POST);
byte[] body = "Hello World".getBytes("UTF-8");
FileCopyUtils.copy(body, request.getBody());
request.execute();
FileCopyUtils.copy(body, request.getBody());
}
@Test(expected = IllegalStateException.class)
public void headersAfterExecute() throws Exception {
ClientHttpRequest request = factory.createRequest(new URI("http://localhost:8889/echo"), HttpMethod.POST);
request.getHeaders().add("MyHeader", "value");
byte[] body = "Hello World".getBytes("UTF-8");
FileCopyUtils.copy(body, request.getBody());
request.execute();
request.getHeaders().add("MyHeader", "value");
}
/**
* Servlet that returns and error message for a given status code.
*/