Closed ryochin closed 2 years ago
If you want to send an empty body (and therefor set content-length: 0
) you should set the body as ""
instead of nil
.
If you instead set the body as nil
then no body will be sent and a content-length: 0
would be incorrect in that case.
Agreed with @ericmj. Thanks anyways @ryochin! 💟
Some servers return the 411 HTTP status code when the Content-Length header field is missing on POST requests. I notice that happens at the first request of Digest Auth using Tesla, for example.