User tests: Successful: Unsuccessful:
Pull Request for Issue #38963 and #42973 and an alternative fix to #43002
In #35568 a change was merged into the JHTTP socket driver, increasing the accepted HTTP version for the client from 1.0 to 1.1.
That change introduce the issue described in #38963: HTTP 1.1 defines the chunked transfer mode which is mandatory for all clients implementing HTTP 1.1 - as our socket-based client however does not support chunked responses, a chunked response causes an infinite loop.
The fix (as used in other similar http libraries such as guzzle is to simply ensure the connection is closed at the end of the request). This is now implemented. Additionally we now default the stream library to http 1.1 as well - as this currently would use HTTP 1.0 in < PHP 8 and HTTP 1.1 in PHP >= 8.0 and I believe would hit similar issues.
I've already fixed this in the framework too but it needs someone there to do a release - see joomla-framework/http@3.0.1...3.x-dev
$http = \Joomla\CMS\Http\HttpFactory::getHttp([], 'socket'); $response = $http->get('https://update.joomla.org/cms/root.json');
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
PR-5.1-dev
|
Can you explain what you think is broken with the chunked encoding? As far as I can see after this PR I get a fully normal json response. there's a bug in the redirect handling too - but trying to do one thing at a time - but I can get responses to longer documents like joomla.org too
@wilsonge I've created a demo file that's always going to output a chunked response. Now, call that file with a HTTP client of choice (i.e. Postman) and the socket driver.
Expected result:
This is Chunk #0.This is Chunk #1.This is Chunk #2.This is Chunk #3.This is Chunk #4.This is Chunk #5.This is Chunk #6.This is Chunk #7.This is Chunk #8.This is Chunk #9.
Actual result:
11
This is Chunk #0.
11
This is Chunk #1.
11
This is Chunk #2.
11
This is Chunk #3.
11
This is Chunk #4.
11
This is Chunk #5.
11
This is Chunk #6.
11
This is Chunk #7.
11
This is Chunk #8.
11
This is Chunk #9.
0
I'm struggling to test this but found an old docs page on an old PHP Manual archive for the PECL HTTP Package with some sample polyfill code and reworked that into something that I think works. I still am struggling to reproduce - but found this https://jigsaw.w3.org/HTTP/ChunkedScript and I think this makes it work? I'm not sure if I'm stripping line breaks improperly or not after. But it definitely removes the extra characters.
Category | Libraries | ⇒ | Administration com_cpanel Libraries |
Category | Libraries Administration com_cpanel | ⇒ | Libraries |
This pull request has been automatically rebased to 5.2-dev.
Title |
|
Labels |
Added:
Feature
PR-5.2-dev
Removed: PR-5.1-dev |
This pull request has been automatically rebased to 5.3-dev.
Title |
|
Labels |
Added:
PR-5.3-dev
Removed: PR-5.2-dev |
@wilsonge the PR solves the issue of unterminated connections caused by the missing header, however I don’t see how it fixes the missing support for the chunked transfer encoding?