v2 / vlib / net / http / build_request_headers_test.v
11 lines · 10 sloc · 473 bytes · ec5eeb57b2bef46b327dd81aacd39946f12b1c00
Raw
1module http
2
3fn test_build_request_headers_with_empty_body_adds_content_length_zero() {
4 // Create a request with no data.
5 mut req := Request{}
6 // Build the headers for it. Ensure that Content-Length: 0 is added
7 // for requests without a body, which is required by some servers.
8 // We use a POST request, as it is most likely to be affected by this.
9 headers := req.build_request_headers(.post, 'localhost', 80, '/')
10 assert headers.contains('Content-Length: 0\r\n')
11}
12