HTTP response 411 Required length, Http Client 4.0.1 Android

I send an HTTP request to google reader api and get an unusual response code. following the documentation, I requested an authentication code and included it in the header of each request. after doing the login and getting the authentication code, I tried to access this URL, which is part of the documentation:

http://www.google.com/reader/api/0/stream/items/contents

when I send a request, I get a status code 411, which should mean "Required Length". the length, as I found, should be the length, in octets, of the message body. There is no message body in this request. there is only one heading, the POST parameter i = "element identifier" and the URL itself. I tried setting the "Content-Length" header to "0" and also to "-1" to no avail.

What is really interesting is that the same code worked fine before google changed its authorization procedure. obviously they have changed something else ...

so my question is what EXACTLY will call the response code 411 and how can I prevent it?

+3
source share
1 answer

This error occurs only with POST and PUT request types, since these two types (types) expect to have a request body that includes request parameters (both text and attachments).

However, as the documentation suggests, this is pretty much an outdated value, and realistically web services should handle requests without relying on Content-Length.

So this is not the problem of the sender of the request, but it is (I would say) a service-side error.

However, setting the Content-Length (mind the own capitalization) request header to 0 should be a workaround.

+2
source

Source: https://habr.com/ru/post/1753810/


All Articles