简体   繁体   中英

Guzzle 6 - How to pass query to redirects

I'm struggling to find out if there is a way to ask Guzzle to pass a query on to redirects. So that if I were to say

          $res = $client->request("GET", "https://google.com", [

                    'allow_redirects' => true,
                    'timeout' => 2000,
                    'query' => ['foo'=>'bar'],
          ]);

And lets say that (for some bizarre reason) google redirected to https://somewhere-else.com , I would like my foobar query to be passed on to that URL too

https://somewhere-else.com?foo=bar

Would love some help with this.

Thanks

There is no standard mechanism in Guzzle to do that, because (as @Calimero already said) the HTTP spec doesn't assume this behaviour.

But you can copy and modify the RedirectMiddleware , that Guzzle uses to handle allow_redirects option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM