-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[Http] Request infos are lost when there is a redirect #6564
Comments
You can set the param strictredirects to TRUE on Zend\Http\Client and set the response code to 302.
OR using the Redirect Controller Plugin
|
Yes but if the I understand if I disabled strictredirects (default behavior), it should reflect what a browser do (POST -> GET and resets GET/POST parameters) but IFAIR, the headers are still forwarded. Am I right? Btw, I'm not speaking about the response headers but the request ones. |
Let me see if a understood: You have a Request (made from browser or other type of client, with certain headers) -> ZF2 receives it, process and return Response (302) -> Browser/client get the response, process, sees the redirect code and send a new Request to the target Location; You need certain headers to be in the last Request. That is it? In this case, I think the second Request is out of scope of ZF2. |
No, I do a request with the zf2 http client ( To resume: I send the request (with headers) to a server, the server returns a 302, the client resend the request to the location in the response headers but here, it does not forward the original request headers to the location. |
@egeloen What you're observing is actually the documented behavior; from http://framework.zend.com/manual/1.12/en/zend.http.client.advanced.html:
As such, not an issue -- this is by design, to keep compatibility with similar clients. Set the |
Sorry, meant to link to http://framework.zend.com/manual/2.3/en/modules/zend.http.client.advanced.html -- but it's the same text, because it's the same behavior in both ZF1 and ZF2. |
@weierophinney Unfortunatelly, I must disagree on the fact zf1 and zf2 behaves same about headers. The zf1 clients keeps the original headers as you can see here. The |
@egeloen it might help if you could say specifically which request headers you are expecting to be preserved. |
@tfountain There is no specific headers, I just expects zf2 to forward any original request headers. For example, I do: $client
->setUri('http://my-url.com')
->setMethod('GET')
->setHeaders(array('user-agent' => 'my user agent'));
->send() Given |
ping @weierophinney |
@egeloen that's probably because a new request is built. Can you look at existing tests and add assertions? |
Any progress here? I guess I'm having the same issue now. |
This issue has been closed as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html |
Hey!
I'm digging into an issue with the http client. When I follow redirects, the request infos (more precisely headers) are lost due to this line https://github.com/zendframework/zf2/blob/master/library/Zend/Http/Client.php#L930 and more precisely this line https://github.com/zendframework/zf2/blob/master/library/Zend/Http/Client.php#L479 which forgot everything about the previous request.
If someone points me the way to fix it, I can provide a PR.
The text was updated successfully, but these errors were encountered: