The Content-Length header is not included in requests
See original GitHub issueBug Report
Description
The Content-Length
header is not included in requests. I did not find out how to prevent this. Is it intentional or actually a bug? I did not find relevant documentation on this behavior of Fuel .
This keeps Fuel ⛽ from being used for APIs that respond with HTTP 411 is the field is not present. This is the case for example with the Google Play Developer API.
To Reproduce
Code to reproduce the behavior:
import com.github.kittinunf.fuel.Fuel
import com.github.kittinunf.fuel.core.Headers
println(Fuel
.post("https://httpbin.org/anything")
.header(Headers.CONTENT_LENGTH, "0")
.responseString()
.third
.component1())
Output:
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "Java/13.0.1",
"X-Amzn-Trace-Id": "Root=1-XXXXXXX-XXXXXXXXXXXXXXXXX"
},
"json": null,
"method": "POST",
"origin": "--------",
"url": "https://httpbin.org/anything"
}
Expected behavior
A clear and concise description of what you expected to happen.
Environment
Development Machine
- OS: Windows 10
- Fuel version: 2.2.2
- Kotlin version: 1.3.72 @ Java/13.0.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
What's the "Content-Length" field in HTTP header?
It's the number of bytes of data in the body of the request or response. The body is the part that comes after...
Read more >Content-Length - HTTP - MDN Web Docs
The Content-Length header indicates the size of the message body, in bytes, sent to the recipient. Header type, Request header, ...
Read more >Content-Length header is missing in POST/DELETE/PUT ...
I believe this is a bug as we're not following the RFC: A user agent SHOULD send a Content-Length in a request message...
Read more >How do I send a POST request with Content-Length Header?
A Content-Length header is a number that indicates the size of the data in the body of the request or response in bytes....
Read more >HTTP/1.1: HTTP Message
The presence of a message-body in a request is signaled by the inclusion of a Content-Length or Transfer-Encoding header field in the request's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, that actually fixes it:
Is that change wanted/should I open a PR?
Yes this is great.