question

RajeshVoleti-4097 avatar image
RajeshVoleti-4097 asked ·

Content-Length in request header of Microsoft Translator is mandatory or not?


As per the below link, 'Content-Length' is required in the request headers of Microsoft Translator API request.

https://docs.microsoft.com/en-gb/azure/cognitive-services/Translator/reference/v3-0-translate

However, we observed that the translations are getting successful even if we don't pass this request header attribute.

It will be really helpful if someone can confirm whether this 'Content-Length' request header attribute is a mandatory field or not.

If required, please provide the convention details to provide the length of the request body like characters count (converting request body into string and get chars count) or KiB or code points or any other..

azure-cognitive-servicesazure-translator
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DenisBalan avatar image
DenisBalan answered ·

Starting from HTTP/1.1 Content-Length header is present in RFC.
This represents the size of body in bytes that client send to receiver part.

RFC does not state mandatoriness of the header, altrought all major HTTP libraries and browser are calculating and sending this header.

You should note that if you are trying to send a request without this header, the receiver part would "guess" either by terminating byte or CLRF sequence endinding of your request.

Short answer, if you can, send it, will do no harm.

https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13

Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.