Skip to content

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

@timeteos

Description

@timeteos

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 (?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions