hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Bassous (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCLIENT-951) Incorrect handling of InputStreams when connecting to a server that requires authentication
Date Mon, 23 Aug 2010 19:48:16 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-951?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12901563#action_12901563
] 

Richard Bassous commented on HTTPCLIENT-951:
--------------------------------------------

OK..

The new log has no wire just context:

it's not failing all the time, just intermittently,  in this case there was one pass and one
fail after it.

I am suspecting that the socket is not getting closed properly from the pass?
although I am calling
httpclient.getConnectionManager().shutdown();


Here are the logs:

08-23 13:11:27.759 D/: Get connection: HttpRoute[{s}->https://.com], timeout = 10000
08-23 13:11:27.767 D/: [HttpRoute[{s}->https://.com]] total kept alive: 0, total issued:
0, total allocated: 0 out of 20
08-23 13:11:27.767 D/: No free connections [HttpRoute[{s}->https://.com]][null]
08-23 13:11:27.767 D/: Available capacity: 2 out of 2 [HttpRoute[{s}->https://.com]][null]
08-23 13:11:27.767 D/: Creating new connection [HttpRoute[{s}->https://.com]]
08-23 13:11:27.876 D/: Connecting to .com/*.*.*.*:443
08-23 13:11:28.509 D/: CookieSpec selected: best-match
08-23 13:11:28.540 D/: Attempt 1 to execute request
08-23 13:11:28.540 D/: Sending request: POST /UploadFiles.aspx HTTP/1.1
08-23 13:11:28.556 D/: >> POST /UploadFiles.aspx HTTP/1.1
08-23 13:11:28.556 D/: >> Cache-Control: no-cache
08-23 13:11:28.556 D/: >> Pragma: no-cache
08-23 13:11:28.556 D/: >> Authorization: Basic ****
08-23 13:11:28.556 D/: >> ty: 0
08-23 13:11:28.556 D/: >> v: 252
08-23 13:11:28.556 D/: >> u: A000002201F102
08-23 13:11:28.556 D/: >> postType: 1
08-23 13:11:28.556 D/: >> filenum: 0
08-23 13:11:28.556 D/: >> pl: 1
08-23 13:11:28.556 D/: >> on: 1
08-23 13:11:28.556 D/: >> mf: 5
08-23 13:11:28.556 D/: >> Transfer-File-Name: file1
08-23 13:11:28.556 D/: >> Transfer-File-Chunk-Count: 1
08-23 13:11:28.556 D/: >> Transfer-File-Chunk: 0
08-23 13:11:28.556 D/: >> filelength: 39024636
08-23 13:11:28.556 D/: >> Cookie: ASP.NET_SessionId=v2jltw45cmu4wtiznidhavnx; path=/;
HttpOnly
08-23 13:11:28.556 D/: >> Content-Length: 39024636
08-23 13:11:28.556 D/: >> Content-Type: binary/octet-stream
08-23 13:11:28.556 D/: >> Host: .com
08-23 13:11:28.556 D/: >> Connection: Keep-Alive
08-23 13:13:12.150 D/: Get connection: HttpRoute[{s}->https://.com], timeout = 10000
08-23 13:13:12.150 D/: [HttpRoute[{s}->https://.com]] total kept alive: 0, total issued:
0, total allocated: 0 out of 20
08-23 13:13:12.150 D/: No free connections [HttpRoute[{s}->https://.com]][null]
08-23 13:13:12.150 D/: Available capacity: 2 out of 2 [HttpRoute[{s}->https://.com]][null]
08-23 13:13:12.150 D/: Creating new connection [HttpRoute[{s}->https://.com]]
08-23 13:13:12.197 D/: Connecting to .com/*.*.*.*:443
08-23 13:13:12.868 D/: CookieSpec selected: best-match
08-23 13:13:12.868 D/: Attempt 1 to execute request
08-23 13:13:12.868 D/: Sending request: POST /UploadFiles.aspx HTTP/1.1
08-23 13:13:12.876 D/: >> POST /UploadFiles.aspx HTTP/1.1
08-23 13:13:12.876 D/: >> Cache-Control: no-cache
08-23 13:13:12.876 D/: >> Pragma: no-cache
08-23 13:13:12.876 D/: >> Authorization: Basic ****
08-23 13:13:12.876 D/: >> ty: 0
08-23 13:13:12.876 D/: >> v: 252
08-23 13:13:12.876 D/: >> u: A000002201F102
08-23 13:13:12.876 D/: >> postType: 1
08-23 13:13:12.876 D/: >> filenum: 0
08-23 13:13:12.876 D/: >> pl: 1
08-23 13:13:12.876 D/: >> on: 1
08-23 13:13:12.876 D/: >> mf: 5
08-23 13:13:12.884 D/: >> Transfer-File-Name: file2
08-23 13:13:12.884 D/: >> Transfer-File-Chunk-Count: 1
08-23 13:13:12.884 D/: >> Transfer-File-Chunk: 0
08-23 13:13:12.884 D/: >> filelength: 39024636
08-23 13:13:12.884 D/: >> Cookie: ASP.NET_SessionId=v2jltw45cmu4wtiznidhavnx; path=/;
HttpOnly
08-23 13:13:12.884 D/: >> Content-Length: 39024636
08-23 13:13:12.884 D/: >> Content-Type: binary/octet-stream
08-23 13:13:12.884 D/: >> Host: .com
08-23 13:13:12.884 D/: >> Connection: Keep-Alive
08-23 13:13:57.556 D/: Connection closed
08-23 13:13:57.587 D/: Closing the connection.
08-23 13:13:57.587 D/: Connection closed
08-23 13:13:57.650 I/: I/O exception (java.io.IOException) caught when processing request:
SSL shutdown failed: I/O error during system call, Broken pipe
08-23 13:13:57.665 D/: SSL shutdown failed: I/O error during system call, Broken pipe
08-23 13:13:57.665 D/: java.io.IOException: SSL shutdown failed: I/O error during system call,
Broken pipe
08-23 13:13:57.665 D/:       at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.nativeclose(Native
Method)
08-23 13:13:57.665 D/:       at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.close(OpenSSLSocketImpl.java:958)
08-23 13:13:57.665 D/:       at org.apache41.http.impl.SocketHttpClientConnection.close(SocketHttpClientConnection.java:259)
08-23 13:13:57.665 D/:       at org.apache41.http.impl.conn.DefaultClientConnection.close(DefaultClientConnection.java:162)
08-23 13:13:57.665 D/:       at org.apache41.http.impl.conn.AbstractPooledConnAdapter.close(AbstractPooledConnAdapter.java:152)
08-23 13:13:57.665 D/:       at org.apache41.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:129)
08-23 13:13:57.665 D/:       at org.apache41.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:623)
08-23 13:13:57.665 D/:       at org.apache41.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:453)
08-23 13:13:57.665 D/:       at org.apache41.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)
08-23 13:13:57.665 D/:       at org.apache41.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:625)
08-23 13:13:57.665 D/:       at org.apache41.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:603)
08-23 13:13:57.665 D/:       at hg.a(ProGuard:2446)
08-23 13:13:57.665 D/:       at b.a(ProGuard:1962)
08-23 13:13:57.665 D/:       at b.a(ProGuard:1563)
08-23 13:13:57.665 D/:       at e.run(ProGuard:1509)
08-23 13:13:57.665 I/: Retrying request
08-23 13:13:57.665 D/: Reopening the direct connection.
08-23 13:13:57.665 D/: Connecting to .com/*.*.*.*:443
08-23 13:13:58.025 D/: Cannot retry non-repeatable request
08-23 13:13:58.033 D/: Connection shut down
08-23 13:13:58.033 D/: Released connection is not reusable.
08-23 13:13:58.033 D/: Releasing connection [HttpRoute[{s}->https://.com]][null]
08-23 13:13:58.040 D/: Notifying no-one, there are no waiting threads
08-23 13:13:58.056 E/: null
08-23 13:13:58.056 E/: org.apache41.http.client.ClientProtocolException
08-23 13:13:58.056 E/:   at org.apache41.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:702)
08-23 13:13:58.056 E/:   at org.apache41.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:625)
08-23 13:13:58.056 E/:   at org.apache41.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:603)
08-23 13:13:58.056 E/:   at hg.a(ProGuard:2446)
08-23 13:13:58.056 E/:   at b.a(ProGuard:1962)
08-23 13:13:58.056 E/:   at b.a(ProGuard:1563)
08-23 13:13:58.056 E/:   at e.run(ProGuard:1509)
08-23 13:13:58.056 E/: Caused by: org.apache41.http.client.NonRepeatableRequestException:
Cannot retry request with a non-repeatable request entity.  The cause lists the reason the
original request failed.
08-23 13:13:58.056 E/:   at org.apache41.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:610)
08-23 13:13:58.056 E/:   at org.apache41.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:453)
08-23 13:13:58.056 E/:   at org.apache41.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)
08-23 13:13:58.056 E/:   ... 6 more
08-23 13:13:58.056 E/: Caused by: java.io.IOException: SSL shutdown failed: I/O error during
system call, Broken pipe
08-23 13:13:58.056 E/:   at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.nativeclose(Native
Method)
08-23 13:13:58.056 E/:   at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.close(OpenSSLSocketImpl.java:958)
08-23 13:13:58.056 E/:   at org.apache41.http.impl.SocketHttpClientConnection.close(SocketHttpClientConnection.java:259)
08-23 13:13:58.056 E/:   at org.apache41.http.impl.conn.DefaultClientConnection.close(DefaultClientConnection.java:162)
08-23 13:13:58.056 E/:   at org.apache41.http.impl.conn.AbstractPooledConnAdapter.close(AbstractPooledConnAdapter.java:152)
08-23 13:13:58.056 E/:   at org.apache41.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:129)
08-23 13:13:58.056 E/:   at org.apache41.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:623)
08-23 13:13:58.056 E/:   ... 8 more
08-23 13:13:58.064 D/: Shutting down

> Incorrect handling of InputStreams when connecting to a server that requires authentication
> -------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-951
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-951
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.0 Final, 4.0.1, 4.1 Alpha1, 4.1 Alpha2
>         Environment: Windows XP, Java 1.6.20
>            Reporter: Thierry Guérin
>             Fix For: 4.0.2, 4.1 Alpha3
>
>         Attachments: httpClient.diff, httpClient4.0.x.diff, httpClient4.1.diff, httpClientTrunk.diff,
httpCore.diff, httpCoreTrunk.Diff, testClientAuthentication.diff
>
>
> I'm trying to upload a file to a WebDav server (mod_dav on Apache Web Server 2.2.14)
that has basic (or digest, the result is the same) authentication enabled.
> I'm using the following code:
>         String url = "http://myserver/dir/test2.gif";
>         File file = new File("d:/test2.gif");
>         DefaultHttpClient httpClient = new DefaultHttpClient();
>         HttpPut put = new HttpPut(url);
>         put.setEntity(new InputStreamEntity(new FileInputStream(file), file.length()));
>         
>         URI uri = put.getURI();
>         httpClient.getCredentialsProvider().setCredentials(new AuthScope(uri.getHost(),
uri.getPort()),
>                 getCredentials());
>         put.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
>         HttpResponse response = httpClient.execute(put);
>         System.out.println(response.getStatusLine());
> When running the above code, I'm getting a org.apache.http.client.NonRepeatableRequestException:
Cannot retry request with a non-repeatable request entity. I tested both the latest alpha
& the svn head. Doing the same thing in HttpClient 3.1 worked as expected. 
> This could be normal, as I'm using an InputStream that is indeed not repeatable, but
as I'm also using Expect: 100-Continue, the stream shouldn't have been consumed with the first
connection (the one that gets a code 401 from the WebDav server), and only in the second one,
when the credentials are provided.
> The problem is that DefaultRequestDirector.execute doesn't take this into account and
assumes that if a request has been tried once, its associated entity (if any) has been consumed.
> Here's the fix that I came up with:
> Change DefaultRequestDirector.execute so that if the wrapper is an EntityEnclosingRequestWrapper,
it checks if the entity has actually been consumed before throwing a NonRepeatableRequestException.
I'm using the method isStreaming() from HttpEntity, as it's the closest thing to what I was
looking for. Reading the JavaDoc, it could lead to the situation where an entity has started
streaming but has not yet finished, and so is not in a state where it can be used. However
I don't think that's a problem as the javadoc for HttpEntity.getContent() states that it can't
be called two times on a non-repeatable entity, so it's just a matter of when the request
will fail.
> This lead me to also modify InputStreamEntity (from the httpCore project) as it didn't
comply with the javadoc. With these two modifications, The file upload completes successfully.
> I also modified:
>  * TestInputStreamEntity.testBasics() (from the httpCore project) test so that it complies
with getContent()'s Javadoc.
>  * TestDefaultClientRequestDirector.FaultyHttpRequestExecutor because it didn't consume
the entity's content.
> All the tests from both httpCore and httpClient pass.
> I tested both InputStreamEntity and BasicHttpEntity.
>  
> Please keep in mind that I am by no means an httpClient (or http, for that matter) expert,
and these modifications may have some unexpected side-effects that I did not foresee, contain
plain dumb code, or whatever, so it would be great if someone could review my changes and
give their opinion.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message