Skip to content

Commit 624a75c

Browse files
jukkarAnas Nashif
authored andcommitted
samples: net: http-server: Do not set Content-Length
As per https://tools.ietf.org/html/rfc7230#section-3.3.2: "A sender MUST NOT send a Content-Length header field in any message that contains a Transfer-Encoding header field." Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 956f47a commit 624a75c

File tree

1 file changed

+0
-14
lines changed
  • samples/net/http_server/src

1 file changed

+0
-14
lines changed

samples/net/http_server/src/main.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ static int http_response(struct http_ctx *ctx, const char *header,
110110
const char *payload, size_t payload_len,
111111
char *str)
112112
{
113-
char content_length[6];
114113
int ret;
115114

116115
ret = http_add_header(ctx, header, str);
@@ -119,19 +118,6 @@ static int http_response(struct http_ctx *ctx, const char *header,
119118
return ret;
120119
}
121120

122-
ret = snprintk(content_length, sizeof(content_length), "%zd",
123-
payload_len);
124-
if (ret <= 0 || ret >= sizeof(content_length)) {
125-
ret = -ENOMEM;
126-
return ret;
127-
}
128-
129-
ret = http_add_header_field(ctx, "Content-Length", content_length, str);
130-
if (ret < 0) {
131-
NET_ERR("Cannot add Content-Length HTTP header (%d)", ret);
132-
return ret;
133-
}
134-
135121
ret = http_add_header(ctx, HTTP_CRLF, str);
136122
if (ret < 0) {
137123
return ret;

0 commit comments

Comments
 (0)