jesusgonzalezrivera
jesusgonzalezrivera

Reputation: 385

Ignore Content-Length of an http response

I need to make an http request to an external service which indicates that it has a mismatch on the Content-Length of its response. I can't find information about how to ignore that Content-Length or if it affects to the length of the response body.

This is the code that I have been using to make the request:

req = Net::HTTP::POST.new(url, headers)
req.body = body
http = Net::HTTP.new(url.host, url.port)
response = http.request(req)
body = JSON.parse(response.body)

Upvotes: 0

Views: 1236

Answers (1)

roman-roman
roman-roman

Reputation: 2796

First of all, it's very unlikely that the Content-Length is not set correctly by any service, as it's virtually never set manually, it belongs to the underlying HTTP layer itself, and is set with corresponding libraries which are thoroughly tested.

And even if it's not, I don't think it's a good idea to "ignore" it, better contact the service provider and point them to the error.

Upvotes: 4

Related Questions