fuel: httpDelete did not send body payload
Fuel: v1.12.0
I tried to sent HTTP DELETE with JSON body. I checked HttpClient.kt that it skip body set up for GET, DELETE, HEAD
private fun setDoOutput(connection: HttpURLConnection, method: Method) = when (method) {
Method.GET, Method.DELETE, Method.HEAD -> connection.doOutput = false
Method.POST, Method.PUT, Method.PATCH -> connection.doOutput = true
}
Should we allow Method.DELETE? Because I have scenario that API need body payload for DELETE.
Same issue #245
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 32 (4 by maintainers)
Commits related to this issue
- Allow body for delete requests (#306) — committed to strangeAeon/Fuel by deleted user 6 years ago
- Allow body for delete requests (#306) — committed to strangeAeon/Fuel by deleted user 6 years ago
I noticed curl response contained HTTP/2 200. I don’t know HttpUrlConnection able to support HTTP/2.
@babedev @simonharrer @kittinunf @SleeplessByte @kmcgill88
Guys I am going to pick this up I have opened a WIP Pr (https://github.com/kittinunf/Fuel/pull/417)
I would really appreciate your feedback and reviews.
Just as a datapoint, RequestBody with DELETE wasn’t working for me on
1.13.0, and after upgrading to1.16.0it is working for me. I’m not discounting @smallufo 's report, just letting you know that in my case it is working.Alright. This might be an issue on our side. I will try some things out over here and see if I can make this work (and write a test so it doesn’t fail again/regression)
I try to remove the
Accept-Encodingheader ,which generates this :
curl -i -X DELETE -d "{\"fields\": [\"persistent_menu\"]}" -H "Content-Type:application/json" https://graph.facebook.com/v3.2/me/messenger_profile?access_token=EAAGpxxxThe result is the same : failed in kotlin code , success in curl console.
If I remove
Content-Typeheader (which leads empty header) , it won’t pass FB (both code and cURL) . SoContent-Typeheader is mandatory here.Sorry , isn’t it what I have already done ?
The result is as the screenshot I pasted.
Wow , I don’t know Fuel has
curlStringfunction , great. This is my result :curl -i -X DELETE -d "{\"fields\": [\"persistent_menu\"]}" -H "Accept-Encoding:compress;q=0.5, gzip;q=1.0" -H "Content-Type:application/json" https://graph.facebook.com/v3.2/me/messenger_profile?access_token=EAAGpXXXBUT , very interesting . After I copy the curlString to console and execute , it is OK !!!
This is so weird.
Before, the spec defined that the body SHOULD be ignored (and therefore a lot of clients did not allow for a
DELETErequest’s body, but this was updated with RFC7231:https://tools.ietf.org/html/rfc7231#section-4.3.5
Therefore, even though current users might not need this as a feature, it SHOULD be implemented.
Yeah, I think by the time I have designed this base on the RFC spec. It is not specified as permitted or not so that I didn’t follow through with the implementation for this. However, most of the modern HTTP libraries support this so we should support it too!
@babedev Would you mind creating a PR for this? I can help you out as well.