Euphoria Ticket #834: http_get does not follow redirects

"http://www.iana.org/domains/example/" retrieves only an empty string "http://www.iana.org/domains/example" retrieves the content.

Should it work with the slash?

Details

Type: Bug Report Severity: Normal Category: Library Routine
Assigned To: unknown Status: Duplicate Reported Release:
Fixed in SVN #: View VCS: none Milestone: 4.0.6

1. Comment by CoJaBo2 Jan 13, 2013

Yes, it should work; this should probably be retitled so actual cause is more clear: "http_get does not follow redirects".

This shouldn't be a difficult fix; http_get would need to check if the status code is 3xx, and restart the request with the URL in the Location header instead (note that this does NOT apply to POST requests, which require special handling; generally, the request is converted to GET after redirect).

Major gotcha here- very few web apps follow the spec that the Location header must be a full URL; a work-around for that bug will be necessary.

There should probably be a parameter "redirect_limit" or similar (defaulting to, say, 10) to specify how many it should follow (which, if set to 0, would either keep the current behavior or just error out). It may also be wise to hardcode an absolute maximum for that value as well..

2. Comment by useless_ Jan 13, 2013

CoJaBo said : Major gotcha here- very few web apps follow the spec that the Location header must be a full URL; a work-around for that bug will be necessary.

I don't believe you, need examples and proof.

useless
(I learned to say that from CoJaBo and jimcbrown)

3. Comment by SDPringle Jan 13, 2013

fixed a typo

4. Comment by jimcbrown Jan 13, 2013

I think we should apply what I'd like to call the "m_sabal standard" here ( http://openeuphoria.org/forum/m/120453.wc )

However, imo the evidence seems to support CoJaBo's assertion. See http://core.trac.wordpress.org/ticket/14062 and http://www.webmasterworld.com/google/3172713.htm - good grief, even w3.org wasn't always compliant!

5. Comment by SDPringle Jan 13, 2013

There is a follow_redirects parameter.

6. Comment by jimcbrown Jan 13, 2013

Yes, but it's unimplemented.

7. Comment by jimcbrown Jan 13, 2013

Duplicate of http://openeuphoria.org/ticket/781.wc

8. Comment by CoJaBo2 Jan 13, 2013

"CoJaBo said : Major gotcha here- very few web apps follow the spec that the Location header must be a full URL; a work-around for that bug will be necessary.
I don't believe you, need examples and proof. "

The PHP documentation is the most obvious source; http://php.net/manual/en/function.header.php ;
The mandate for absolute URL is clearly documented, but completely ignored by the writers of example code in most of the comments, which is then copy-pasted to quite a few other tutorials, simply because "it worked" in whatever browser they happened to test with.

As jimcbrown points out, even older versions of Wordpress have this bug; frankly, I'm surprised they fixed it, given their record.

Search



Quick Links

User menu

Not signed in.

Misc Menu