kwhitley / itty-durable

Cloudflare Durable Objects + Itty Router = shorter code
MIT License
236 stars 18 forks source link

Passing DO content as HTTP header causes warnings in Wrangler when using Unicode #41

Open AlCalzone opened 11 months ago

AlCalzone commented 11 months ago

I'm not 100% certain that this will cause issues in production, but this change https://github.com/kwhitley/itty-durable/commit/eaf73a2f82dcbd5c2060aea3887f60e60dc96390#diff-5cd6061dc976728ee25d4ddb3302dddcaffd5ddd0846ffd06f96bde8bdad1331R58 causes Wrangler to complain about invalid header values when the payload sent to the DO contains Unicode characters:

Invalid header name or value: "["�",["Keys"]]". Per the Fetch specification, the Headers class may only accept header names and values which contain 8-bit characters. That is, they must not contain any Unicode code points greater than 0xFF. As a quirk, we are encoding this string in UTF-8 in the header, but in a browser this would result in a TypeError exception. Consider encoding this string in ASCII for compatibility with browser implementations of the Fetch specification.