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?
https://tools.ietf.org/html/rfc7230#section-3.3
Without this some tools don't work well, for example wrk.
Is valid code, although has some issues, the first one is the header is not set (or any other header).
Compared with the minimal out of the box set by the http module of node:
Can these values be set automatically?