reactphp-http-proxy icon indicating copy to clipboard operation
reactphp-http-proxy copied to clipboard

Move to a v2-compatible HTTP implementation

Open Crell opened this issue 7 months ago • 4 comments

This library currently depends on ringcentral/psr7. However, that appears to be abandoned, and only supports PSR-7 v1. Just about everything else has moved to PSR-7 v2, which adds types.

This causes a problem when this package is a transitive dependency, as it means an application using it must use psr/http-message v1, not v2. But some libraries now require v2, making them mutually incompatible.

This is causing issues upstream. See:

https://github.com/reactphp/http/pull/545 https://github.com/reactphp/http/pull/542

Changing the dependency to the more widely used nyholm/psr7 (which supports v2) would resolve this chain of dependencies, and allow React HTTP to be used alongside PSR-7 v2.

Crell avatar Jun 10 '25 16:06 Crell

Changing the dependency to the more widely used nyholm/psr7 (which supports v2) would resolve this chain of dependencies, and allow React HTTP to be used alongside PSR-7 v2.

That sadly won't solve it, purely because of this function call. Had a look at this recently but haven't found a solution for it yet: https://github.com/clue/reactphp-http-proxy/blob/1.x/src/ProxyConnector.php#L187

WyriHaximus avatar Jun 10 '25 20:06 WyriHaximus

@WyriHaximus I am not sure if I butchered this, but it seems like the only part of the RingCentral/PSR7 library that is being used is just to grab the response code and reason from the HTTP reposes first line. All the other header processing is done, but subsequently ignored. There doesn't appear to be any validation or error checking provided either, so I just added a simple regex match to replace the functionality.

kwhat avatar Jun 11 '25 03:06 kwhat

@kwhat Correct, didn't even look that far, was also checking possible libraries and seeing if they provide that functionality. Funny enough, we have exactly this in react/http where this quest initially started 🤣

WyriHaximus avatar Jun 11 '25 19:06 WyriHaximus

@Crell FYI IMHO this looks like a good fix: https://github.com/clue/reactphp-http-proxy/pull/65

WyriHaximus avatar Jun 23 '25 13:06 WyriHaximus