A bug of DELETE method of `wp_remote_post` in v4.6 beta4
-
I want to send a DELETE request that contain a JSON data to a server, in the stable version (4.5), I can do it like this:
wp_remote_post($url,[ 'method' => 'DELETE', 'body' => ['tags' => ['example',],], 'timeout' => 20, ]);
it is equals to:
$ curl $url -X DELETE -H "Content-Type: application/json" --data '{"tags":["example"]}'
It’s all works well in stable version
but in the beta version, it doesn’t work at all, first, the Content-Type header is not
application/json
, it sendapplication/x-www-form-urlencoded
, and the data is in url encoded type but not json, I edited the code like this:wp_remote_post($url,[ 'method' => 'DELETE', 'headers' => [ 'Content-Type' => 'application/json', ], 'body' => json_encode(['tags' => ['blog-'.$fsckeycdn_blog_id,],]), 'timeout' => 20, ]);
but it still doesn’t work, the data is not send as POST method, but it is like GET method, the json data is send in
QUERY_STRING
, I can got nothing infile_get_contents("php://input")
I also tried this:
wp_remote_post($url,[ ? 'method' => 'POST', ? 'headers' => [ 'Content-Type' => 'application/json', ], ? 'body' => json_encode(['tags' => ['example',],]), 'timeout' => 20, ]);
This works well, it not like GET method, I can got data in
file_get_contents("php://input")
I think this is a bug, the function
wp_remote_request
also has this problem.
- The topic ‘A bug of DELETE method of `wp_remote_post` in v4.6 beta4’ is closed to new replies.