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

Rajesh Voleti 1 Reputation point

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

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 Translator
Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
368 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,642 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Denis Balan 6 Reputation points

    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.

    1 person found this answer helpful.
    0 comments No comments