How to disable URL encoding in Guzzle 6

2019-09-07 20:40发布

问题:

I'm working with pipedrive API and I want to make such a request:

GET https://api.pipedrive.com/v1/deals(id,title,value,currency)?api_token=YOUR_API_TOKEN

It works fine eg. when I do the request with a browser, but when I send the request with Guzzle I get response 501. I assume that it gets encoded in a way that's not recognized by Pipedrive API.

Is there a way to disable URL encoding in Guzzle 6?

回答1:

Seems like this is a bug and I'm not the only one facing this issue:

  • https://github.com/guzzle/guzzle/issues/1121
  • https://github.com/guzzle/psr7/commit/962735c754f2a562a619b456a3aa4e614f0e5360

Commit message:

Fixing path URI encoding.

The previous pattern was incorrect:
    '/(?:[^' . self::$charUnreserved . ':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/'

The new pattern now properly follows RFC 3986:
    /(?:[^a-zA-Z0-9_\-\.~!\$&'\(\)\*\+,;=:@\/%]+|%(?![A-Fa-f0-9]{2}))/

This pattern now allows the following characters: "(", ")", "*", "!", "'"


标签: php guzzle psr-7