Disable urlencode in POST request in Guzzle

 ̄綄美尐妖づ 提交于 2020-01-15 11:14:32

问题


I am trying to post some data and Guzzle automatically urlencode() all post values. I want to disable it because its acting weird (There is a problem with the Enter character). I searched the documentation and found a reference about this

$query->useUrlEncoding(false);

but its about GET requests.

Also documentation says : "URL encoding can be disabled by passing false, enabled by passing true, set to use RFC 1738 by passing Query::FORM_URLENCODED (internally uses PHP's urlencode function), or set to RFC 3986 by passing Query::RFC_3986 (this is the default and internally uses PHP's rawurlencode function)."

Any idea how to do this?


回答1:


For those looking, Guzzle has been completely rewritten & the docs are not yet 100%

The method is now on the Query object, and can be set like:

$request->getQuery()->setEncodingType(false);




回答2:


Do it like this:

$request->getQuery()->useUrlEncoding(false);

Check out their API Doc for more info http://api.guzzlephp.org/class-Guzzle.Http.QueryString.html



来源:https://stackoverflow.com/questions/24003118/disable-urlencode-in-post-request-in-guzzle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!