On Mon, 2008-11-17 at 14:07 -0500, Simon Wilkinson wrote:
> Hi,
>
> I have the following code to set up a Put method:
>
> HttpClient client = new HttpClient();
>
> PutMethod httpPut = new PutMethod(httpUrl);
> File file = new File(localFilePath);
>
> httpPut.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
> new DefaultHttpMethodRetryHandler(5, false));
>
> httpPut.setRequestEntity(new InputStreamRequestEntity(new
> FileInputStream(file)));
>
> httpPut.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE,
> true);
>
> httpPut.setContentChunked(true);
> httpPut.setRequestHeader("Content-Type",
> "application/octet-stream"); //$NON-NLS-1$ //$NON-NLS-2$
> httpPut.setRequestHeader("Connection", "keep-alive");
> //$NON-NLS-1$//$NON-NLS-2$
> httpPut.setRequestHeader("Content-Length", ""+file.length());
> //$NON-NLS-1$ //$NON-NLS-2$
>
> try {
> client.executeMethod(httpPut);
>
> if (httpPut.getStatusCode() == HttpStatus.SC_OK) {
> System.out.println(httpPut.getResponseBodyAsString());
> } else {
> System.out.println("Unexpected failure: " +
> httpPut.getStatusLine().toString()); //$NON-NLS-1$
> }
> }catch(Exception e) {
> throw new Exception(e);
> } finally {
> httpPut.releaseConnection();
> }
>
> After every file is uploaded (successfully) I get the following line:
>
> Unexpected failure: HTTP/1.1 400 Bad Request
>
> Here is the ouput with the header wire + context logging enabled for a
> successful upload with the error at the end:
>
> 2008/11/17 14:07:21:924 EST [DEBUG] DefaultHttpParams - Set parameter
> http.method.retry-handler =
> [EMAIL PROTECTED]
> 2008/11/17 14:07:21:940 EST [DEBUG] DefaultHttpParams - Set parameter
> http.protocol.expect-continue = true
> 2008/11/17 14:07:21:940 EST [DEBUG] HttpConnection - Open connection
> to virtvc5:443
> 2008/11/17 14:07:21:940 EST [DEBUG] header - >> "PUT
> /folder/4ed084dc-3b8f-4b66-a4f9-3bbc49adfd07/DummyWindows.vmx?dcPath=a/b/virtDC5&dsName=storage1
> HTTP/1.1[\r][\n]"
> 2008/11/17 14:07:21:940 EST [DEBUG] HttpMethodBase - Adding Host request
> header
> 2008/11/17 14:07:21:940 EST [DEBUG] header - >> "Cookie:
> vmware_soap_session="16E6FFB7-0FA9-4C85-BBEC-4F58AACD3996"[\r][\n]"
> 2008/11/17 14:07:21:940 EST [DEBUG] header - >> "Content-Type:
> application/octet-stream[\r][\n]"
> 2008/11/17 14:07:21:940 EST [DEBUG] header - >> "Connection:
> keep-alive[\r][\n]"
> 2008/11/17 14:07:21:940 EST [DEBUG] header - >> "Content-Length: 1693[\r][\n]"
> 2008/11/17 14:07:21:940 EST [DEBUG] header - >> "User-Agent: Jakarta
> Commons-HttpClient/3.0-rc2[\r][\n]"
> 2008/11/17 14:07:21:940 EST [DEBUG] header - >> "Host: virtvc5[\r][\n]"
> 2008/11/17 14:07:21:940 EST [DEBUG] header - >> "Expect: 100-continue[\r][\n]"
> 2008/11/17 14:07:21:940 EST [DEBUG] header - >> "[\r][\n]"
> 2008/11/17 14:07:24:940 EST [INFO] HttpMethodBase - 100 (continue)
> read timeout. Resume sending the request
> 2008/11/17 14:07:24:940 EST [DEBUG] EntityEnclosingMethod - Request body sent
> 2008/11/17 14:07:24:940 EST [DEBUG] header - << "HTTP/1.1 400 Bad
> Request[\r][\n]"
> 2008/11/17 14:07:24:940 EST [DEBUG] header - << "Date: Mon, 17 Nov
> 2008 19:03:58 GMT[\r][\n]"
> 2008/11/17 14:07:24:940 EST [DEBUG] header - << "Connection: close[\r][\n]"
> 2008/11/17 14:07:24:940 EST [DEBUG] header - << "Content-Type:
> text/html[\r][\n]"
> 2008/11/17 14:07:24:940 EST [DEBUG] header - << "Content-Length: 50[\r][\n]"
> Unexpected failure: HTTP/1.1 400 Bad Request
> 2008/11/17 14:07:24:940 EST [DEBUG] HttpMethodBase - Should close
> connection in response to directive: close
> 2008/11/17 14:07:24:940 EST [DEBUG] HttpConnection - Releasing
> connection back to connection manager.
>
> Has anybody seen this before, or have any ideas where the unexpected
> failure is coming from, as the functionality seems to be working?
>
> Thanks,
>
> Simon
>
I suppose the server does not support the 'expect-continue' handshaking.
Try disabling it.
Oleg
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]