Skip to content

Content-Length or Transfer-Encoding header (RFC 7230) #86

Description

@jbolila

The presence of a message body in a request is signaled by a Content-Length or Transfer-Encoding header field.

https://tools.ietf.org/html/rfc7230#section-3.3

Without this some tools don't work well, for example wrk.

let data = String::from_utf8_lossy(request.body()).into_owned();
let body = format!(r#"{{"data": {}, "url": "{}"}}"#, request.uri().path(), data);
Ok(response
    .header("content-length", body.len().to_string().as_str())   //  ~:o
    .body(body.into_bytes())?)

Is valid code, although has some issues, the first one is the header is not set (or any other header).

< HTTP/1.1 200 OK
* no chunk, no close, no size. Assume close to signal end

Compared with the minimal out of the box set by the http module of node:

< HTTP/1.1 200 OK
< Date: Sun, 29 Oct 2017 08:19:45 GMT
< Connection: keep-alive
< Content-Length: 21

Can these values be set automatically?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions