Does curl do anything special with non-ASCII characters in HTTP header values?
Date: Sat, 19 Sep 2020 00:19:57 +0000
I was troubleshooting an issue with a REST application, that takes values from a custom HTTP header. In this case, the value contained a "slash-O" character from the Norwegian alphabet (i.e. "ø"). The issue turned out to be due to the server application receiving this character in mangled form.
Curiously though, it took me awhile to find this issue... because it worked perfectly fine when I tested the endpoint with curl!
When I send that character as a header value in Postman, or from a server-to-server HTTP request from another application, then it is received in mangled form. However, it comes through perfectly fine when I test like this:
curl --request POST --header "my-header: ø" --data "dummy payload" http://localhost:8080/my-endpoint
I should probably refactor this application, to not take potentially-non-ASCII values from headers. Or perhaps just manually encode and decode on both ends. But regardless, I'm just dying to understand why this works with curl! Could anyone offer any insight on what curl might be doing with header values... such that non-ASCII characters transmit cleanly, even when they don't from other clients?