Guzzle: How to urldecode query params ?

Created on 12 Jan 2018  路  3Comments  路  Source: guzzle/guzzle

| Q | A
| ------------ | ---
| Bug? | no
| New Feature? | no
| Version | 6.3

Actual Behavior

$customer = \GuzzleHttp\Client(['base_uri'=>'https://example.com']);
$response = $customer->request('GET', '/', ['query'=> ['name'=>'Dolce| Gabana']]);

All is correct except the parameter of the query is urlencoded

https://example.com/?name=Dolce%7CGabana

I want exactly this request uri

https://example.com/?name=Dolce|Gabana

kinquestion kinsupport lifecyclstale

Most helpful comment

IMO you should not want to do that. The remote server must decode the query string, so it will receive the original string in the end. BTW, it's better to use query option to manage query string parameters.

If you want to do it anyway, try to construct an instance of Uri class manually.

All 3 comments

IMO you should not want to do that. The remote server must decode the query string, so it will receive the original string in the end. BTW, it's better to use query option to manage query string parameters.

If you want to do it anyway, try to construct an instance of Uri class manually.

@alexeyshockov is right, URL encoding should not be a problem. I'm afraid manual instantiation won't help either.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings