http-rs / surf

Fast and friendly HTTP client framework for async Rust
https://docs.rs/surf
Apache License 2.0
1.45k stars 119 forks source link

Inconsistent header format #351

Closed Davoodeh closed 1 year ago

Davoodeh commented 1 year ago

Hello, I have no idea if this is important at all or not but since I have never seen such inconsistency I thought maybe I should report it.

I just ran this example (almost identical to examples/post.rs):

    let uri = "http://localhost:3246";
    let res = surf::post(uri)
        .body(http_types::Body::from_string("Login=1".to_string()))
        .await
        .unwrap();
    assert_eq!(res.status(), http_types::StatusCode::Ok);

I have tokio with ["full"] feature as well.

The example above breaks https://github.com/cdfuller/echo-server.git and the reason is that some headers do not have a tailing ` after:`.

Expected

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *

POST / HTTP/1.1
Host: localhost:3246
Accept: */*
Accept-Encoding: deflate, gzip, br, zstd
Content-Type: text/plain;charset=utf-8 <<<<<<<<<<<<<<<<<<<<<<<<<<<
User-Agent: curl/7.84.0 isahc/0.9.14  <<<<<<<<<<<<<<<<<<<<<<<<<<<<
Content-Length: 7

Login=1

Actual

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *

POST / HTTP/1.1
Host: localhost:3246
Accept: */*
Accept-Encoding: deflate, gzip, br, zstd
content-type:text/plain;charset=utf-8
user-agent:curl/7.84.0 isahc/0.9.14
Content-Length: 7

Login=1

P.S: Excuse me if this is not relevant or it is not a big deal. By a fast search, I concluded (maybe too fast) that there is no issues like this here. I just thought it's better said than unsaid. P.P.S: Idk if this is from the client or server but notice that the casing is also inconsistent (altho probably nothing important)

Davoodeh commented 1 year ago

According to https://www.rfc-editor.org/rfc/rfc7230#section-3.2, the space after : is optional and is case insensitive. Therefore, this is not a big deal and logically the server must be updated.