1

I am developing a web api which will accept text/csv data. The users are international and may want to supply dates or numbers in the language of their country, so I need the API to be aware of the language the input is in.

Looking at the Content-Language header, this is used

to describe the language(s) intended for the audience, so that it allows a user to differentiate according to the users' own preferred language.

But I can only find references to this in the context of the response from the server where I want to specify the language of the request.

I haven't seen anything specifically disallowing this header on a request but I cannot find any examples of same.

I also looked at the Accept-Language header but that specifies the language you would like the response to be in so is not suitable in this case.

I could create a custom header for this purpose but would prefer to stick to standards where possible.

freeranger
  • 23
  • 5
  • Use a URL parameter, e.g. `/api/post?lang=fr`. – georgeawg Aug 06 '18 at 09:50
  • _"the former is a response header and the latter a request header"_ - no, that's not the point of the duplicate: _"Content-Language describes the language that a particular piece of content is intended for"_. If you use it on a request, it describes the request content. – CodeCaster Aug 06 '18 at 13:53
  • @georgeawg I am trying to avoid custom params or headers if I can. I'd be surprised if I am the first person to want to specify the language of request data rather than that of the response, so I was hoping that I am missing some other standard header or that I can get clarity on the validity of using Content-Language as a Request header. – freeranger Aug 06 '18 at 13:53
  • The accepted answer is wrong, see first comment under it. It is a content header, not a response header. – CodeCaster Aug 06 '18 at 13:57
  • 1
    @CodeCaster Ah...I misread RFC-2616 - It seemed the header was listed under Response headers but in fact it is not. My apologies, you are correct. – freeranger Aug 06 '18 at 13:59
  • `Content-Language` is both a CORS-safelisted *request-header* and a CORS-safelisted *response-header*. See [this answer](https://stackoverflow.com/a/51710259/5535245) on Stack Overflow. – georgeawg Aug 06 '18 at 14:51

0 Answers0