|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jasonwyz98 at gmail dot com
New email:
PHP Version: OS:


 [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-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 03 18:01:27 2023 UTC