In accordance with RFC 2616, Section 4 , Message headers are defined as follows:
message-header = field-name ":" [ field-value ] field-name = token field-value = *( field-content | LWS ) field-content = <the OCTETs making up the field-value and consisting of either *TEXT or combinations of token, separators, and quoted-string>
Knowing that according to section 2 :
token = 1*<any CHAR except CTLs or separators> separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <"> | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT CHAR = <any US-ASCII character (octets 0 - 127)> quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) qdtext = <any TEXT except <">>
The TEXT rule is used only for the descriptive content of a field and values that are not intended to be interpreted by the message analyzer. The words of * TEXT MAY contain characters from character sets other than ISO-8859-1 only when encoded in accordance with RFC 2047 .
TEXT = <any OCTET except CTLs, but including LWS>
In other words, the header value can only be encoded in ISO-8859-1 if you want to encode characters that are not included in this encoding, which seems to be here, you should encode it in accordance with RFC 2047 , also known as MIME ( Multipurpose Internet Email Extensions). Part Three: Message Header Extensions for Non-ASCII Text
So instead
reason: žšť
He must be
reason: =?utf-8?q?=C5=BE=C5=A1=C5=A5?=
In practice, it is even recommended to encode a value if you do not have only US-ASCII .
The last thing to check on your side is that your JAX-RS implementation supports RFC 2047 , if not, you will need to decode it manually, for example, using the MimeUtility.decodeText(String etext) utility.
Here is a concrete example:
@GET public Response showHeader(@HeaderParam("reason") String reason) throws UnsupportedEncodingException {
Calling this resource method using curl with --header 'reason: =?utf-8?q?=C5=BE=C5=A1=C5=A5?=' Gives as expected:
Value of reason = 'žšť'
NB: To encode your header value from your js interface, you can use the q- library, here is a live demo .