Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

\Request and relative 301 location #7799

Closed
lindesbs opened this issue May 3, 2015 · 6 comments
Closed

\Request and relative 301 location #7799

lindesbs opened this issue May 3, 2015 · 6 comments
Assignees
Labels
Milestone

Comments

@lindesbs
Copy link

lindesbs commented May 3, 2015

Requesting entries from a sitemap http://www.heise.de/sitemap.xml
Those entries are redirected to a relative URL, which is wrong handled by the Request::send function

Array
(
[scheme] => http
[host] => www.heise.de
[path] => /meldung/Hickhack-um-Virtual-Reality-Apps-fuer-Samsungs-Gear-VR-2631443.html
)

Redirect goes to :
Array
(
[path] => /newsticker/meldung/Hickhack-um-Virtual-Reality-Apps-fuer-Samsungs-Gear-VR-2631443.html
)

that means, the redirect here (https://github.com/contao/core/blob/master/system/modules/core/library/Contao/Request.php#L443) has to check, if scheme, host, port exists and rebuild the URL

@leofeyer
Copy link
Member

Is this issue still relevant?

@lindesbs
Copy link
Author

Not for my project, but maybe for the future ? It´s your choice ;-)

@leofeyer
Copy link
Member

Ok, can you explain the problem to me again please? :)

@lindesbs
Copy link
Author

example code :

$request = new \Request();
$request->send($url);
echo $request->response;

sitemap from heise.de, one entry, for example :

$url = "http://www.heise.de/meldung/Kunstprojekt-Random-Darknet-Shopper-geht-wieder-auf-Einkaufstour-3024099.html"

response is a 301.

adding redirect option into request :

$request = new \Request();
$request->redirect=true;
$request->rlimit=8;
$request->send($url);
echo $request->response;

results in 301 too.

This happens cause this line : https://github.com/contao/core/blob/master/system/modules/core/library/Contao/Request.php#L433

The Location in the ResponseHeader has only a relative URL : /newsticker/meldung/Kunstprojekt-Random-Darknet-Shopper-geht-wieder-auf-Einkaufstour-3024099.html

Now the $uri (https://github.com/contao/core/blob/master/system/modules/core/library/Contao/Request.php#L271) is in the second step only :

Array ( [path] => /newsticker/meldung/Kunstprojekt-Random-Darknet-Shopper-geht-wieder-auf-Einkaufstour-3024099.html ) 

and without any scheme, the response and everything else stay with old values (https://github.com/contao/core/blob/master/system/modules/core/library/Contao/Request.php#L287)

--> http error 301

I think, it will be sufficient, in generating an asolute URL based on the request header and the response location, if the response location is an relative URL.

@leofeyer leofeyer added this to the 3.5.6 milestone Nov 27, 2015
@leofeyer leofeyer self-assigned this Nov 27, 2015
@leofeyer
Copy link
Member

I definitely want to fix this! :)

@leofeyer
Copy link
Member

Fixed in 6d12f6b.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants