mirror of https://github.com/apache/jclouds.git
Issue 389: workaround where java urlconnection doesn't set content-length header when it should
This commit is contained in:
parent
e2a8185c10
commit
6bb9d101d1
|
@ -219,20 +219,22 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe
|
|||
// writeTo will close the output stream
|
||||
try {
|
||||
request.getPayload().writeTo(connection.getOutputStream());
|
||||
} catch (IOException e){
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
connection.setRequestProperty(HttpHeaders.CONTENT_LENGTH, "0");
|
||||
// for some reason POST undoes the content length header above.
|
||||
if (connection.getRequestMethod().equals("POST"))
|
||||
connection.setChunkedStreamingMode(0);
|
||||
}
|
||||
return connection;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Only disconnect if there is no content, as disconnecting will throw away
|
||||
* unconsumed content.
|
||||
* Only disconnect if there is no content, as disconnecting will throw away unconsumed content.
|
||||
*/
|
||||
@Override
|
||||
protected void cleanup(HttpURLConnection connection) {
|
||||
|
|
Loading…
Reference in New Issue