Merge pull request #1290 from jclouds/issue1289

bug in zero length put
This commit is contained in:
Adrian Cole 2013-02-01 16:06:10 -08:00
commit 0c1432d88c
5 changed files with 16 additions and 2 deletions

View File

@ -222,8 +222,10 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe
} else {
connection.setRequestProperty(CONTENT_LENGTH, "0");
// for some reason POST/PUT undoes the content length header above.
if (ImmutableSet.of("POST", "PUT").contains(connection.getRequestMethod()))
if (ImmutableSet.of("POST", "PUT").contains(connection.getRequestMethod())) {
connection.setFixedLengthStreamingMode(0);
connection.setDoOutput(true);
}
}
return connection;
}

View File

@ -262,4 +262,9 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
public void testGetAndParseSax() {
assertEquals(client.downloadAndParse(""), "whoppers");
}
@Test(invocationCount = 5, timeOut = 5000)
public void testZeroLengthPut() {
client.putNothing("");
}
}

View File

@ -127,7 +127,7 @@ public abstract class BaseJettyTest {
response.setStatus(SC_OK);
response.getWriter().println(toStringAndClose(request.getInputStream()) + "PUT");
} else {
response.sendError(500, "no content");
response.setStatus(SC_OK);
}
} else if (request.getMethod().equals("POST")) {
// don't redirect large objects

View File

@ -58,6 +58,7 @@ import com.google.inject.Provides;
/**
* Sample test for the behaviour of our Integration Test jetty server.
*
* @see IntegrationTestClient
* @author Adrian Cole
*/
public interface IntegrationTestAsyncClient {
@ -196,6 +197,10 @@ public interface IntegrationTestAsyncClient {
}
@PUT
@Path("/objects/{id}")
ListenableFuture<Void> putNothing(@PathParam("id") String id);
@Provides
StringBuilder newStringBuilder();

View File

@ -60,6 +60,8 @@ public interface IntegrationTestClient {
String downloadAndParse(String id);
void putNothing(String id);
@Provides
StringBuilder newStringBuilder();
}