Feature PR-5.3-dev Pending

User tests: Successful: Unsuccessful:

avatar wilsonge
wilsonge
24 Mar 2024

Pull Request for Issue #38963 and #42973 and an alternative fix to #43002

Summary of Changes

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

Testing Instructions

  • Create a socket-based JHTTP request to a server responding with a chunked response, i.e. by using this code block:
    $http = \Joomla\CMS\Http\HttpFactory::getHttp([], 'socket'); $response = $http->get('https://update.joomla.org/cms/root.json');

Actual result BEFORE applying this Pull Request

  • HTTP 1.0 request but working.

Expected result AFTER applying this Pull Request

  • Response returned

Link to documentations

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

avatar wilsonge wilsonge - open - 24 Mar 2024
avatar wilsonge wilsonge - change - 24 Mar 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 24 Mar 2024
Category Libraries
avatar SniperSister
SniperSister - comment - 24 Mar 2024

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

avatar wilsonge wilsonge - change - 24 Mar 2024
Labels Added: PR-5.1-dev
avatar wilsonge
wilsonge - comment - 24 Mar 2024

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

avatar SniperSister
SniperSister - comment - 25 Mar 2024

@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
b034f84 25 Mar 2024 avatar wilsonge Fix
avatar wilsonge
wilsonge - comment - 25 Mar 2024

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.

261fff0 27 Mar 2024 avatar wilsonge Fix
avatar joomla-cms-bot joomla-cms-bot - change - 27 Mar 2024
Category Libraries Administration com_cpanel Libraries
avatar joomla-cms-bot joomla-cms-bot - change - 27 Mar 2024
Category Libraries Administration com_cpanel Libraries
avatar HLeithner
HLeithner - comment - 24 Apr 2024

This pull request has been automatically rebased to 5.2-dev.

avatar HLeithner HLeithner - change - 24 Apr 2024
Title
[5.1] - Fix JHTTP socket transport http version
[5.2] - Fix JHTTP socket transport http version
avatar HLeithner HLeithner - edited - 24 Apr 2024
avatar richard67 richard67 - change - 12 May 2024
Labels Added: Feature PR-5.2-dev
Removed: PR-5.1-dev
avatar HLeithner
HLeithner - comment - 2 Sep 2024

This pull request has been automatically rebased to 5.3-dev.

avatar HLeithner HLeithner - change - 2 Sep 2024
Title
[5.2] - Fix JHTTP socket transport http version
[5.3] - Fix JHTTP socket transport http version
avatar HLeithner HLeithner - edited - 2 Sep 2024
avatar richard67 richard67 - change - 15 Sep 2024
Labels Added: PR-5.3-dev
Removed: PR-5.2-dev

Add a Comment

Login with GitHub to post a comment