I've set up the following redirect chain.
scratch-redirect-1 -> 302 to
scratch-redirect-2 -> 302 to
scratch-redirect-3 -> 302 to
scratch-redirect-final
Fetches below with max_redirect => 10. In all cases, scratch-redirect-final is the final URL that has its content fetched.
Fetching scratch-redirect-3 I get the following abbreviated response object:
[code] => 200
[redirect_code] => 302
[redirect_url] => http://s/core7/scratch-redirect-final
Fetching scratch-redirect-2 I get the following abbreviated response object:
[code] => 200
[redirect_code] => 302
[redirect_url] => http://s/core7/scratch-redirect-3
Fetching scratch-redirect-1 I get the following abbreviated response object:
[code] => 200
[redirect_code] => 302
[redirect_url] => http://s/core7/scratch-redirect-2
API docs claim:
- redirect_code: If redirected, an integer containing the initial response status code.
- redirect_url: If redirected, a string containing the redirection location.
While I'm not sure what "redirection location" actually means, for 1 step redirects it amounts to the TARGET.
Attached patch changes redirect_url to mean the final url.
Comments
Comment #1
heine commentedComment #2
heine commentedMarking major as it blocks #575810: OpenID discovery spec violation - follow redirects..
Comment #3
bfroehle commentedI've attached a revised patch which breaks the comment at 80 characters. The patch itself is proper and seems ready to me.
Comment #4
wojtha commentedRTBC
It needs to be backported to D6 too.
Comment #5
heine commented*sigh*
Comment #6
heine commentedProbably needs test. Cannot do so atm.
Comment #7
wojtha commentedRerolled patch from #3 by Heine and bfroehle. I added the tests for single and for multiple redirects.
Comment #8
wojtha commentedComment #9
wojtha commentedJust changing redirect code from 302 to 301 in the testing function. This code is more appropriate I think.
Comment #10
wojtha commentedComment #11
dries commentedIt was not really clear what 'final' meant. I had to read up on the example in the issue to understand what it meant. This is minor.
This is written a bit 'wasteful'. If $result->redirect_url is already set, we don't have to overwrite it with itself. We can use a regular if-statement.
Comment #12
wojtha commentedReflecting Dries's notices in #11. I changed redirect_url description to:
redirect_url: If redirected, a string containing the URL of the redirect target... makes more sense now?
Comment #13
sunCan we quickly add a phpDoc here?
Powered by Dreditor.
Comment #14
wojtha commented@sun sure
Comment #15
sunThanks!
Comment #16
webchickLooks like Dries's feedback has been addressed.
Corrected some minor English things (continuos, destinatination) and committed to 8.x and 7.x. Thanks!