You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Charles Honton (JIRA)" <ji...@apache.org> on 2008/09/11 15:33:44 UTC

[jira] Created: (HTTPCLIENT-796) IOException when server closes connection at end of chunk

IOException when server closes connection at end of chunk
---------------------------------------------------------

                 Key: HTTPCLIENT-796
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-796
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient
    Affects Versions: 3.1.1
            Reporter: Charles Honton


My program sending a POST to a server which responds with a chunked response.  Instead of a final 0 length chunk, the server closes the connection.  The following is a redacted log:

>> POST /Activity/ActivityFile.aspx HTTP/1.1[\r][\n]"
>> Referer: https://ranking.ase.com/Activity/ActivityForm.aspx?AI=127910002[\r][\n]
>> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[\r][\n]
>> Host: ranking.ase.com[\r][\n]
>> Cookie: Session=EBFJLZR1D17M12RBX3V; auth-user-info=st75|204402|224243[\r][\n]
>> Content-Length: 55[\r][\n]
>> Content-Type: application/x-www-form-urlencoded[\r][\n]
>> [\r][\n]
>> __EVENTTARGET=&__EVENTARGUMENT=&UserAccount=27910002

<< HTTP/1.1 200 OK[\r][\n]
<< Date: Wed, 10 Sep 2008 16:44:09 GMT[\r][\n]
<< Server: Microsoft-IIS/6.0[\r][\n]
<< X-Powered-By: ASP.NET[\r][\n]
<< X-AspNet-Version: 2.0.50727[\r][\n]
<< content-disposition: inline; filename=JPMC.SFX[\r][\n]
<< Transfer-Encoding: chunked[\r][\n]
<< Cache-Control: private[\r][\n]
<< Content-Type: application/vnd.inu.SFX; charset=utf-8[\r][\n]
<< [\r][\n]
<< 1a[\r][\n]
<< [\r][\n]
The response data[\r][\n]
<< [\r][\n]

java.io.IOException: chunked stream ended unexpectedly
org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:252)
org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
java.io.FilterInputStream.read(Unknown Source)
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:740)
org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:838)
com.cc.wb.WebBrowser.redirectFetch(WebBrowser.java:184)
com.cc.wb.WebBrowser.fetch(WebBrowser.java:235)
com.cc.wb.WebBrowser.postURL(WebBrowser.java:290)
com.cc.wb.Tester.main(Tester.java:41)

The server's behavior is probably not consistent with RFC2616, but it would be nice if http-client could handle this without an IOException.

-- 
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


[jira] Moved: (HTTPCORE-173) IOException when server closes connection at end of chunk

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-173?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski moved HTTPCLIENT-796 to HTTPCORE-173:
-------------------------------------------------------

          Component/s:     (was: HttpClient)
                       HttpCore
    Affects Version/s:     (was: 3.1.1)
                       4.0-beta2
           Issue Type: Wish  (was: Bug)
                  Key: HTTPCORE-173  (was: HTTPCLIENT-796)
              Project: HttpComponents HttpCore  (was: HttpComponents HttpClient)

> IOException when server closes connection at end of chunk
> ---------------------------------------------------------
>
>                 Key: HTTPCORE-173
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-173
>             Project: HttpComponents HttpCore
>          Issue Type: Wish
>          Components: HttpCore
>    Affects Versions: 4.0-beta2
>            Reporter: Charles Honton
>         Attachments: c.patch
>
>
> My program sending a POST to a server which responds with a chunked response.  Instead of a final 0 length chunk, the server closes the connection.  The following is a redacted log:
> >> POST /Activity/ActivityFile.aspx HTTP/1.1[\r][\n]"
> >> Referer: https://ranking.ase.com/Activity/ActivityForm.aspx?AI=127910002[\r][\n]
> >> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[\r][\n]
> >> Host: ranking.ase.com[\r][\n]
> >> Cookie: Session=EBFJLZR1D17M12RBX3V; auth-user-info=st75|204402|224243[\r][\n]
> >> Content-Length: 55[\r][\n]
> >> Content-Type: application/x-www-form-urlencoded[\r][\n]
> >> [\r][\n]
> >> __EVENTTARGET=&__EVENTARGUMENT=&UserAccount=27910002
> << HTTP/1.1 200 OK[\r][\n]
> << Date: Wed, 10 Sep 2008 16:44:09 GMT[\r][\n]
> << Server: Microsoft-IIS/6.0[\r][\n]
> << X-Powered-By: ASP.NET[\r][\n]
> << X-AspNet-Version: 2.0.50727[\r][\n]
> << content-disposition: inline; filename=JPMC.SFX[\r][\n]
> << Transfer-Encoding: chunked[\r][\n]
> << Cache-Control: private[\r][\n]
> << Content-Type: application/vnd.inu.SFX; charset=utf-8[\r][\n]
> << [\r][\n]
> << 1a[\r][\n]
> << [\r][\n]
> The response data[\r][\n]
> << [\r][\n]
> java.io.IOException: chunked stream ended unexpectedly
> org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:252)
> org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
> org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
> java.io.FilterInputStream.read(Unknown Source)
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:740)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:838)
> com.cc.wb.WebBrowser.redirectFetch(WebBrowser.java:184)
> com.cc.wb.WebBrowser.fetch(WebBrowser.java:235)
> com.cc.wb.WebBrowser.postURL(WebBrowser.java:290)
> com.cc.wb.Tester.main(Tester.java:41)
> The server's behavior is probably not consistent with RFC2616, but it would be nice if http-client could handle this without an IOException.

-- 
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


[jira] Updated: (HTTPCLIENT-796) IOException when server closes connection at end of chunk

Posted by "Charles Honton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCLIENT-796?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Charles Honton updated HTTPCLIENT-796:
--------------------------------------

    Attachment: c.patch

Patch to parameterize behavior when server closes connection instead of specifying trailing zero byte chunk

> IOException when server closes connection at end of chunk
> ---------------------------------------------------------
>
>                 Key: HTTPCLIENT-796
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-796
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 3.1.1
>            Reporter: Charles Honton
>         Attachments: c.patch
>
>
> My program sending a POST to a server which responds with a chunked response.  Instead of a final 0 length chunk, the server closes the connection.  The following is a redacted log:
> >> POST /Activity/ActivityFile.aspx HTTP/1.1[\r][\n]"
> >> Referer: https://ranking.ase.com/Activity/ActivityForm.aspx?AI=127910002[\r][\n]
> >> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[\r][\n]
> >> Host: ranking.ase.com[\r][\n]
> >> Cookie: Session=EBFJLZR1D17M12RBX3V; auth-user-info=st75|204402|224243[\r][\n]
> >> Content-Length: 55[\r][\n]
> >> Content-Type: application/x-www-form-urlencoded[\r][\n]
> >> [\r][\n]
> >> __EVENTTARGET=&__EVENTARGUMENT=&UserAccount=27910002
> << HTTP/1.1 200 OK[\r][\n]
> << Date: Wed, 10 Sep 2008 16:44:09 GMT[\r][\n]
> << Server: Microsoft-IIS/6.0[\r][\n]
> << X-Powered-By: ASP.NET[\r][\n]
> << X-AspNet-Version: 2.0.50727[\r][\n]
> << content-disposition: inline; filename=JPMC.SFX[\r][\n]
> << Transfer-Encoding: chunked[\r][\n]
> << Cache-Control: private[\r][\n]
> << Content-Type: application/vnd.inu.SFX; charset=utf-8[\r][\n]
> << [\r][\n]
> << 1a[\r][\n]
> << [\r][\n]
> The response data[\r][\n]
> << [\r][\n]
> java.io.IOException: chunked stream ended unexpectedly
> org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:252)
> org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
> org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
> java.io.FilterInputStream.read(Unknown Source)
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:740)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:838)
> com.cc.wb.WebBrowser.redirectFetch(WebBrowser.java:184)
> com.cc.wb.WebBrowser.fetch(WebBrowser.java:235)
> com.cc.wb.WebBrowser.postURL(WebBrowser.java:290)
> com.cc.wb.Tester.main(Tester.java:41)
> The server's behavior is probably not consistent with RFC2616, but it would be nice if http-client could handle this without an IOException.

-- 
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


[jira] Resolved: (HTTPCORE-173) IOException when server closes connection at end of chunk

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-173?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCORE-173.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0-beta3

HttpCore will tolerate the missing closing chunk if the chunk coded content is terminated by the end of stream (EOF) condition of the closed connection.

Oleg

> IOException when server closes connection at end of chunk
> ---------------------------------------------------------
>
>                 Key: HTTPCORE-173
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-173
>             Project: HttpComponents HttpCore
>          Issue Type: Wish
>          Components: HttpCore
>    Affects Versions: 4.0-beta2
>            Reporter: Charles Honton
>             Fix For: 4.0-beta3
>
>         Attachments: c.patch
>
>
> My program sending a POST to a server which responds with a chunked response.  Instead of a final 0 length chunk, the server closes the connection.  The following is a redacted log:
> >> POST /Activity/ActivityFile.aspx HTTP/1.1[\r][\n]"
> >> Referer: https://ranking.ase.com/Activity/ActivityForm.aspx?AI=127910002[\r][\n]
> >> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[\r][\n]
> >> Host: ranking.ase.com[\r][\n]
> >> Cookie: Session=EBFJLZR1D17M12RBX3V; auth-user-info=st75|204402|224243[\r][\n]
> >> Content-Length: 55[\r][\n]
> >> Content-Type: application/x-www-form-urlencoded[\r][\n]
> >> [\r][\n]
> >> __EVENTTARGET=&__EVENTARGUMENT=&UserAccount=27910002
> << HTTP/1.1 200 OK[\r][\n]
> << Date: Wed, 10 Sep 2008 16:44:09 GMT[\r][\n]
> << Server: Microsoft-IIS/6.0[\r][\n]
> << X-Powered-By: ASP.NET[\r][\n]
> << X-AspNet-Version: 2.0.50727[\r][\n]
> << content-disposition: inline; filename=JPMC.SFX[\r][\n]
> << Transfer-Encoding: chunked[\r][\n]
> << Cache-Control: private[\r][\n]
> << Content-Type: application/vnd.inu.SFX; charset=utf-8[\r][\n]
> << [\r][\n]
> << 1a[\r][\n]
> << [\r][\n]
> The response data[\r][\n]
> << [\r][\n]
> java.io.IOException: chunked stream ended unexpectedly
> org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:252)
> org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
> org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
> java.io.FilterInputStream.read(Unknown Source)
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:740)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:838)
> com.cc.wb.WebBrowser.redirectFetch(WebBrowser.java:184)
> com.cc.wb.WebBrowser.fetch(WebBrowser.java:235)
> com.cc.wb.WebBrowser.postURL(WebBrowser.java:290)
> com.cc.wb.Tester.main(Tester.java:41)
> The server's behavior is probably not consistent with RFC2616, but it would be nice if http-client could handle this without an IOException.

-- 
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


[jira] Commented: (HTTPCORE-173) IOException when server closes connection at end of chunk

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635981#action_12635981 ] 

Oleg Kalnichevski commented on HTTPCORE-173:
--------------------------------------------

Ming

Feel free to provide a patch. However, please make sure to update the affected test cases as well. 

Oleg  

> IOException when server closes connection at end of chunk
> ---------------------------------------------------------
>
>                 Key: HTTPCORE-173
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-173
>             Project: HttpComponents HttpCore
>          Issue Type: Wish
>          Components: HttpCore
>    Affects Versions: 4.0-beta2
>            Reporter: Charles Honton
>         Attachments: c.patch
>
>
> My program sending a POST to a server which responds with a chunked response.  Instead of a final 0 length chunk, the server closes the connection.  The following is a redacted log:
> >> POST /Activity/ActivityFile.aspx HTTP/1.1[\r][\n]"
> >> Referer: https://ranking.ase.com/Activity/ActivityForm.aspx?AI=127910002[\r][\n]
> >> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[\r][\n]
> >> Host: ranking.ase.com[\r][\n]
> >> Cookie: Session=EBFJLZR1D17M12RBX3V; auth-user-info=st75|204402|224243[\r][\n]
> >> Content-Length: 55[\r][\n]
> >> Content-Type: application/x-www-form-urlencoded[\r][\n]
> >> [\r][\n]
> >> __EVENTTARGET=&__EVENTARGUMENT=&UserAccount=27910002
> << HTTP/1.1 200 OK[\r][\n]
> << Date: Wed, 10 Sep 2008 16:44:09 GMT[\r][\n]
> << Server: Microsoft-IIS/6.0[\r][\n]
> << X-Powered-By: ASP.NET[\r][\n]
> << X-AspNet-Version: 2.0.50727[\r][\n]
> << content-disposition: inline; filename=JPMC.SFX[\r][\n]
> << Transfer-Encoding: chunked[\r][\n]
> << Cache-Control: private[\r][\n]
> << Content-Type: application/vnd.inu.SFX; charset=utf-8[\r][\n]
> << [\r][\n]
> << 1a[\r][\n]
> << [\r][\n]
> The response data[\r][\n]
> << [\r][\n]
> java.io.IOException: chunked stream ended unexpectedly
> org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:252)
> org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
> org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
> java.io.FilterInputStream.read(Unknown Source)
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:740)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:838)
> com.cc.wb.WebBrowser.redirectFetch(WebBrowser.java:184)
> com.cc.wb.WebBrowser.fetch(WebBrowser.java:235)
> com.cc.wb.WebBrowser.postURL(WebBrowser.java:290)
> com.cc.wb.Tester.main(Tester.java:41)
> The server's behavior is probably not consistent with RFC2616, but it would be nice if http-client could handle this without an IOException.

-- 
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


[jira] Commented: (HTTPCLIENT-796) IOException when server closes connection at end of chunk

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12630358#action_12630358 ] 

Oleg Kalnichevski commented on HTTPCLIENT-796:
----------------------------------------------

Charles,

HttpClient 3.x code line is no longer being developed beyond fixing critical bugs. HttpClient 3.x is very unlikely to see another public release. Please consider porting these changes to HttpClient 4.0 / HttpCore

Oleg  

> IOException when server closes connection at end of chunk
> ---------------------------------------------------------
>
>                 Key: HTTPCLIENT-796
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-796
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 3.1.1
>            Reporter: Charles Honton
>         Attachments: c.patch
>
>
> My program sending a POST to a server which responds with a chunked response.  Instead of a final 0 length chunk, the server closes the connection.  The following is a redacted log:
> >> POST /Activity/ActivityFile.aspx HTTP/1.1[\r][\n]"
> >> Referer: https://ranking.ase.com/Activity/ActivityForm.aspx?AI=127910002[\r][\n]
> >> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[\r][\n]
> >> Host: ranking.ase.com[\r][\n]
> >> Cookie: Session=EBFJLZR1D17M12RBX3V; auth-user-info=st75|204402|224243[\r][\n]
> >> Content-Length: 55[\r][\n]
> >> Content-Type: application/x-www-form-urlencoded[\r][\n]
> >> [\r][\n]
> >> __EVENTTARGET=&__EVENTARGUMENT=&UserAccount=27910002
> << HTTP/1.1 200 OK[\r][\n]
> << Date: Wed, 10 Sep 2008 16:44:09 GMT[\r][\n]
> << Server: Microsoft-IIS/6.0[\r][\n]
> << X-Powered-By: ASP.NET[\r][\n]
> << X-AspNet-Version: 2.0.50727[\r][\n]
> << content-disposition: inline; filename=JPMC.SFX[\r][\n]
> << Transfer-Encoding: chunked[\r][\n]
> << Cache-Control: private[\r][\n]
> << Content-Type: application/vnd.inu.SFX; charset=utf-8[\r][\n]
> << [\r][\n]
> << 1a[\r][\n]
> << [\r][\n]
> The response data[\r][\n]
> << [\r][\n]
> java.io.IOException: chunked stream ended unexpectedly
> org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:252)
> org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
> org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
> java.io.FilterInputStream.read(Unknown Source)
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:740)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:838)
> com.cc.wb.WebBrowser.redirectFetch(WebBrowser.java:184)
> com.cc.wb.WebBrowser.fetch(WebBrowser.java:235)
> com.cc.wb.WebBrowser.postURL(WebBrowser.java:290)
> com.cc.wb.Tester.main(Tester.java:41)
> The server's behavior is probably not consistent with RFC2616, but it would be nice if http-client could handle this without an IOException.

-- 
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


[jira] Commented: (HTTPCLIENT-796) IOException when server closes connection at end of chunk

Posted by "Ming Fai (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635113#action_12635113 ] 

Ming Fai commented on HTTPCLIENT-796:
-------------------------------------

I've encountered the same problem with core 4.0beta1. Looks like IIS sends out incorrect chunk header.

by 
 - disabling the TestChunkCoding.testCorruptChunkedInputStreamNoClosingChunk, and
 - at ChunkedInputStream, changing from
{code}
        if (i == -1) {
            throw new MalformedChunkCodingException(
                    "Chunked stream ended unexpectedly");
        }
{code}
to
{code}
        if (i < 0) {
            return 0;
        }
{code}

I'm able to get rid of the exception and able to download a malformed chunked response. I could provide a patch if you want. I suppose httpclient should handle malformed chunked response, but i'm not sure if it should be configurable like the original patch.

> IOException when server closes connection at end of chunk
> ---------------------------------------------------------
>
>                 Key: HTTPCLIENT-796
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-796
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 3.1.1
>            Reporter: Charles Honton
>         Attachments: c.patch
>
>
> My program sending a POST to a server which responds with a chunked response.  Instead of a final 0 length chunk, the server closes the connection.  The following is a redacted log:
> >> POST /Activity/ActivityFile.aspx HTTP/1.1[\r][\n]"
> >> Referer: https://ranking.ase.com/Activity/ActivityForm.aspx?AI=127910002[\r][\n]
> >> User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)[\r][\n]
> >> Host: ranking.ase.com[\r][\n]
> >> Cookie: Session=EBFJLZR1D17M12RBX3V; auth-user-info=st75|204402|224243[\r][\n]
> >> Content-Length: 55[\r][\n]
> >> Content-Type: application/x-www-form-urlencoded[\r][\n]
> >> [\r][\n]
> >> __EVENTTARGET=&__EVENTARGUMENT=&UserAccount=27910002
> << HTTP/1.1 200 OK[\r][\n]
> << Date: Wed, 10 Sep 2008 16:44:09 GMT[\r][\n]
> << Server: Microsoft-IIS/6.0[\r][\n]
> << X-Powered-By: ASP.NET[\r][\n]
> << X-AspNet-Version: 2.0.50727[\r][\n]
> << content-disposition: inline; filename=JPMC.SFX[\r][\n]
> << Transfer-Encoding: chunked[\r][\n]
> << Cache-Control: private[\r][\n]
> << Content-Type: application/vnd.inu.SFX; charset=utf-8[\r][\n]
> << [\r][\n]
> << 1a[\r][\n]
> << [\r][\n]
> The response data[\r][\n]
> << [\r][\n]
> java.io.IOException: chunked stream ended unexpectedly
> org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInputStream(ChunkedInputStream.java:252)
> org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInputStream.java:221)
> org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStream.java:176)
> java.io.FilterInputStream.read(Unknown Source)
> org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:108)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:740)
> org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:838)
> com.cc.wb.WebBrowser.redirectFetch(WebBrowser.java:184)
> com.cc.wb.WebBrowser.fetch(WebBrowser.java:235)
> com.cc.wb.WebBrowser.postURL(WebBrowser.java:290)
> com.cc.wb.Tester.main(Tester.java:41)
> The server's behavior is probably not consistent with RFC2616, but it would be nice if http-client could handle this without an IOException.

-- 
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