net-http icon indicating copy to clipboard operation
net-http copied to clipboard

content-type is set by default even for empty body

Open mullermp opened this issue 3 years ago • 0 comments

Generic request will supply a default content-type of application/x-www-form-urlencoded - https://github.com/ruby/net-http/blob/a0fab1ab52c52d37d21241a86eba6d958ff1c4db/lib/net/http/generic_request.rb#L299

While this is helpful, this can have negative consequences, and we cannot disable the behavior. In cases where there is no body, or body is set and empty, the content-type is set. In these cases, content-type should not be set at all. It must be set to something to avoid the behavior.

So I'm opening this issue to start discussion. Is it possible that:

  1. Net::HTTP does not supply default content type for empty body?
  2. Is it ok to introduce an option on request to turn off this behavior?
  3. Net::HTTP default content type is application/octet-stream instead of application/x-www-form-urlencoded

mullermp avatar Sep 30 '21 17:09 mullermp