Skip to content

Commit c90b633

Browse files
jukkarnashif
authored andcommitted
samples: net: dumb_http_server: Check EOF while skipping headers
If recv() returns 0 bytes, then terminate the connection. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent fdde0b0 commit c90b633

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

samples/net/sockets/dumb_http_server/src/socket_dumb_http.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ int main(void)
8686
char c;
8787

8888
r = recv(client, &c, 1, 0);
89+
if (r == 0) {
90+
goto close_client;
91+
}
92+
8993
if (r < 0) {
9094
if (errno == EAGAIN || errno == EINTR) {
9195
continue;

0 commit comments

Comments
 (0)