Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to handle uri with colon. #1550

Closed
azusa0127 opened this issue Aug 5, 2016 · 6 comments
Closed

Unable to handle uri with colon. #1550

azusa0127 opened this issue Aug 5, 2016 · 6 comments

Comments

@azusa0127
Copy link

azusa0127 commented Aug 5, 2016

I have an api with colon in the uri syntax ('/document/demo/22:0'), which is not able to be correctly parsed by guzzle.

It is likely to be the issue of php function parse_url() as the error says
"InvalidArgumentException: Unable to parse URI: /document/demo/22:0 in /var/www/html/demo/vendor/guzzlehttp/psr7/src/Uri.php:53 Stack trace: ..."

Not sure if this is a general issue or a special case in php7.

Versions:
guzzle 6.2.1
php 7.0.8-0ubuntu0.16.04.2

@alexeyshockov
Copy link
Collaborator

Please, check you full URI. Because a colon works well on both PHP 5.6 & 7.0:

$ psysh
Psy Shell v0.7.2 (PHP 7.0.8 — cli) by Justin Hileman
>>> parse_url('http://example.com/document/demo/22:0')
=> [
     "scheme" => "http",
     "host" => "example.com",
     "path" => "/document/demo/22:0",
   ]

@azusa0127 azusa0127 changed the title Unable to handle uri with comma. Unable to handle uri with colon. Aug 5, 2016
@azusa0127
Copy link
Author

azusa0127 commented Aug 6, 2016

Thanks for helping, @alexeyshockov. After your inspiration I've done some more debugs and find out the $uri passed in to the parse_url() function was the string "/document/demo/22:0", not the full string with host and port.

As you may confirm the result in Repl.it, it seems like parse_url() had treated the colon as the delimiter for (host) and (port)

PHP 7.0.8 (cli) (built: Jun 23 2016 23:39:14) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
   parse_url("/document/demo/22:0");
=> false
   parse_url("/document/demo/22");
=> {"path":"\/document\/demo\/22"}

So, I end up with solving my case by passing in the full uri with host and ports included. But this is still a bug either of faulty implementation parse_url() from php, or an improper usage of parse_url() of guzzle.

Should I change this issue into a bug report?

@Tobion
Copy link
Member

Tobion commented Aug 16, 2016

There is already a long-standing bug report for that on PHP. IMO this can be closed as it should be fixed by php. Also the problem is more in https://github.com/guzzle/psr7 and not here.

@mtdowling
Copy link
Member

Agreed with Tobion -- this is a PHP stdlib issue.

@c960657
Copy link

c960657 commented Sep 29, 2016

FWIW, the PHP bug is this:
#71646: parse_url fails to parse relative url with port-like string in url

Previously reported in #55511 broken parse_url, but that was marked as Bogus.

@brayandev2
Copy link

brayandev2 commented Apr 20, 2017

I "solve" this issue putting the URL like this:

/api/v1/rest/account/advertiser:1

for this:

'/api/v1/rest/account/advertiser:1?

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

No branches or pull requests

6 participants