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

Decode inserts malformed date header #193

Open
brosander opened this issue Sep 1, 2021 · 2 comments
Open

Decode inserts malformed date header #193

brosander opened this issue Sep 1, 2021 · 2 comments

Comments

@brosander
Copy link

res.insert_header(DATE, &format!("date: {}\r\n", date)[..]);

I'm seeing date header values like

Header date -> [
        "date: Wed, 01 Sep 2021 17:42:04 GMT\r\n",
]

Where date: and \r\n are both included in the value of the header.

I think

   if res.header(DATE).is_none() {
        let date = fmt_http_date(std::time::SystemTime::now());
        res.insert_header(DATE, &format!("date: {}\r\n", date)[..]);
    }

Should be

   if res.header(DATE).is_none() {
        let date = fmt_http_date(std::time::SystemTime::now());
        res.insert_header(DATE, &format!("{}", date)[..]);
    }
@brosander
Copy link
Author

Other headers for reference

Header date -> [
        "date: Wed, 01 Sep 2021 17:42:04 GMT\r\n",
    ]
Header content-type -> [
        "application/json",
    ]
Header content-length -> [
        "211",
    ]

@yoshuawuyts
Copy link
Member

@brosander ooph, yes that's a great catch! Your suggested fix also makes a lot of sense. Would you be willing to file a PR implementing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants