Mr Guliarte
Mr Guliarte

Reputation: 739

HTTP: What header to add in order to set the charset?

I got this Java code at my RESTFul Web Service:

 Response response = Response.ok().
             entity(method(paramether)).
             header("Access-Control-Allow-Origin", "*").build();

I want to add some header that lets me set the charset to UTF-8 through the HTTP itself (because I'm facing some problems when trying to set only at the document). Thanks in advance.

Upvotes: 0

Views: 54

Answers (2)

MrWerbenjagermanjensen
MrWerbenjagermanjensen

Reputation: 386

The Content-Type header can be used to specify the type of the content you return, along with it's character set.

As an example:

Content-Type: text/html; charset=utf-8

Taken from the Wikipedia article on HTTP headers https://en.wikipedia.org/wiki/List_of_HTTP_header_fields

Upvotes: 0

Andy Turner
Andy Turner

Reputation: 140299

Content-Type, e.g.:

Content-Type: text/html;charset=UTF-8

Upvotes: 1

Related Questions