How to reset CURLOPT_CUSTOMREQUEST

后端 未结 3 1836
被撕碎了的回忆
被撕碎了的回忆 2021-01-11 12:12

I’m using a REST API which, among other things, uses the DELETE method like this:

DELETE /resources/whatever/items/123

To acce

3条回答
  •  有刺的猬
    2021-01-11 12:40

    This is actually a bug in PHP, since the original documentation states the following:

    Restore to the internal default by setting this to NULL.

    Unfortunately, as you can see from the source code, the option value gets cast to a string before it's passed to the underlying library.

    Solution

    I've written a pull request that addresses the issue and allows for NULL to be passed for the CURLOPT_CUSTOMREQUEST option value.

    The above patch will take some time to get merged into the project, so until then you would have to explicitly set the method yourself once you start using this option.

    Update

    The fix has been applied to 5.5.11 and 5.6.0 (beta1).

提交回复
热议问题