|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59179 HttpRequest->getUrl() returns the wrong scheme
Submitted: 2010-04-26 05:48 UTC Modified: 2010-04-28 02:46 UTC
From: jasonwyz98 at gmail dot com Assigned: mike (profile)
Status: Wont fix Package: pecl_http (PECL)
PHP Version: 5.3.2 OS: Ubuntu 9.10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-04-26 05:48 UTC] jasonwyz98 at gmail dot com

HttpRequest->getUrl() returns the wrong scheme, it doesn't handle the scheme HTTPS.

ex. If I access a resource via https://localhost/test.php

the getUrl() method returns "http://localhost/test.php" instead of "https://localhost/test.php"


Reproduce code:
1. Create a file test.php with the following code:

$req = HttpMessage::fromEnv( \HttpMessage::TYPE_REQUEST )->toMessageTypeObject();

echo $req->getUrl();

Expected result:

Actual result:

It should be "https"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-27 09:30 UTC]
Well, acutally that's not totally true.

The message does not know the scheme it was sent/accessed/delivered, as it loos like:

GET /test.php HTTP/1.1
Host: localhost

- REQUEST_URI actually is "/test.php" only in HttpMessage::fromEnv().

- in HttpMessage->toMessageTypeObject() the message checks if it has a "Host" header to adapt the request url.

You might want to overreide the request's url with the ENV's URL:

 [2010-04-27 23:32 UTC] jasonwyz98 at gmail dot com
Hi Mike

I see your point, but can we test $_SERVER['HTTPS'] or similar to see if it's set and determine whether it's http/https.

This would make pecl_http extension more robust.

 [2010-04-28 02:46 UTC]
Hi Jason, no you actually didn't see my point, sorry.

What I meant to say is, that the message does not care how it was transported, and at the time of the call of toMessageTypeObject() it doesn't know it has been scraped from the environment.

Though, I'm still open for meaningful suggestions.

Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 11:01:34 2024 UTC