jenssegers / php-proxy

A PHP proxy script with https and post support
https://jenssegers.com
933 stars 266 forks source link

GuzzleAdapter removes query parameters if Request doesn't contain headers #26

Closed andig closed 9 years ago

andig commented 9 years ago

Root cause is in Symfony, full description see here: https://github.com/symfony/symfony/issues/14400

Should this have a workaround in GuzzleAdapter by , e.g. by setting the REQUEST_URI header before converting it to string in https://github.com/jenssegers/php-proxy/blob/master/src/Adapter/Guzzle/GuzzleAdapter.php#L67?

jenssegers commented 9 years ago

Looks like something Symfony should fix rather than adding a workaround?

andig commented 9 years ago

My scenario is building the Symfony request by hand so I could even fix it in the source system. I've raised it here as I thought others might stumble about the same issue. The thing is that GuzzleAdapter claims it can send a Request to an arbitry uri. This is exactly what doesn't work as the Requests string representation has to contain the uri. I fear that Symfony will decline solution as they cannot really create fully valid HTTP headers without making an assumption about the uri which they cant know unless GuzzleAdapter shares its knowledge?

Makes sense?

andig commented 9 years ago

Looks like something Symfony should fix rather than adding a workaround?

Convinced. As I've noticed, Request::create() does already take care of the headers. I didn't notice that as it does not handle my edge case of having a POST request with query parameters.

jenssegers commented 9 years ago

So the proposed workaround would be to set REQUEST_URI in $_SERVER and then restore it after it is converted?

andig commented 9 years ago

So the proposed workaround would be to set REQUEST_URI in $_SERVER

This is what Request::create() does, yes. My mistake was using new Request() instead without taking care of the special headers.

and then restore it after it is converted?

As far as I understand it the REQUEST_URI header is a php-specific thing without standards meaning. Therefore no reason to restore it to anything.