2

I am using Advanced REST Client Application (Chrome plugin) to perform authentication using HTTP header and it works.

X-Username: member
X-Password: abc123

However when I tried to use non english username

X-Username: 阿里巴巴
X-Password: abc123

I get the following error

Unable set request header: X-Username: 阿里巴巴

How can I set a request header to use Chinese character if it's possible ?

abiieez
  • 3,139
  • 14
  • 57
  • 110

1 Answers1

3

According to the specification RFC 7230 (HTTP 1.1):

Historically, HTTP has allowed field content with text in the ISO-8859-1 charset [ISO-8859-1], supporting other charsets only through use of [RFC2047] encoding. In practice, most HTTP header field values use only a subset of the US-ASCII charset [USASCII]. Newly defined header fields SHOULD limit their field values to US-ASCII octets. A recipient SHOULD treat other octets in field content (obs-text) as opaque data.

That said, there is a standard HTTP header for credentials, the Authorization one. You can use the basic authentication and its content would be encoded with base64:

Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==

The value after Basic is the encoded value of the string username:password. For more details about such mechanism, see this link: https://en.wikipedia.org/wiki/Basic_access_authentication.

See also this answer for more details: What encoding should I use for HTTP Basic Authentication?.

Hope it helps you, Thierry

Community
  • 1
  • 1
Thierry Templier
  • 198,364
  • 44
  • 396
  • 360