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

Rajesh Voleti 1 Reputation point
2020-05-18T15:15:19.803+00:00

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

https://learn.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 Services
Azure Cognitive Services
A group of Azure artificial intelligence services and cognitive APIs that help build intelligent apps.
1,146 questions
Azure Translator
Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
247 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Denis Balan 6 Reputation points
    2020-05-18T15:57:20.513+00:00

    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

    1 person found this answer helpful.
    0 comments No comments