HTTP Headers use byte->string/utf-8
Tim Brown <[email protected]>
| Newsgroups | gmane.comp.lang.racket.user,gmane.lisp.scheme.plt |
|---|---|
| Message-ID | <[email protected]> |
Folks, I have a web server, which in production is receiving a user agent in its header which includes the phrase: #"FBCR/M\351ditel" It seems to be a mobile from Morocco. I’m forcing the request-headers/raw promise on my request; and I get: “bytes->string/utf-8: string is not a well-formed UTF-8 encoding” Which it isn’t. I then investigated (searched on StackOverflow[1], more like) what character set should be used for HTTP headers. In turn I was pointed to [2]: > 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. Do you agree that the headers’ string conversion for HTTP (at least, I don’t know about other network protocols) should be done using: bytes->string/latin-1 -- which should support LATIN-1 as well as its subset US-ASCII, as we’d hope for in the future? Tim [1] http://stackoverflow.com/questions/4400678/http-header-should-use-what-character-encoding [2] https://tools.ietf.org/html/rfc7230#section-3.2.4 -- Tim Brown CEng MBCS <[email protected]> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ City Computing Limited · www.cityc.co.uk City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB T:+44 20 8770 2110 · F:+44 20 8770 2130 ──────────────────────────────────────────────────────────────────────── City Computing Limited registered in London No:1767817. Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE VAT No: GB 918 4680 96 -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.