Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't encode utf-8 strings in headers #491

Open
timeteos opened this issue Aug 28, 2024 · 0 comments
Open

Can't encode utf-8 strings in headers #491

timeteos opened this issue Aug 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@timeteos
Copy link

Description

Failure to encode utf-8 strings into headers

Steps to Reproduce

let password = "brocolis🥦";

let req = Request::get("https://exemple.com")
    .header("Content-Type", "application/json")
    .header("pswd", password);

Throws the following error in http/headers.rs at line 62 : Cannot convert argument 2 to ByteString because the character at index 8 has value 55358 which is greater than 255.

Probably that there should be some error handling in those functions :

pub fn set(&self, name: &str, value: &str) {
    self.raw.set(name, value).unwrap_throw()
}

Here is some code to easily reproduce the error : reproduct.zip

Expected Behavior

String are just an array of u8, so I would expect the header to be sent with the ASCII representation of the utf-8 string (?)

@timeteos timeteos added the bug Something isn't working label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant