mirror of https://github.com/apache/jclouds.git
fix issue #1289 bug in zero length put
This commit is contained in:
parent
adf9cd5802
commit
865005afd9
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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("");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ public interface IntegrationTestClient {
|
|||
|
||||
String downloadAndParse(String id);
|
||||
|
||||
void putNothing(String id);
|
||||
|
||||
@Provides
|
||||
StringBuilder newStringBuilder();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue