Skip to content

Commit d82566c

Browse files
committed
Fix tcp_hello_world test to receive all the data from http response
1 parent 47390e6 commit d82566c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

TESTS/netsocket/tcp_hello_world/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ void test_tcp_hello_world() {
7676
sock.send(buffer, strlen(buffer));
7777

7878
// Server will respond with HTTP GET's success code
79-
const int ret = sock.recv(buffer, sizeof(buffer) - 1);
80-
buffer[ret] = '\0';
79+
int ret = 0;
80+
int bytes_recvd = 0;
8181

82+
do {
83+
ret += bytes_recvd;
84+
bytes_recvd = sock.recv(buffer+ret, sizeof(buffer) - 1 - ret);
85+
}while(bytes_recvd > 0);
86+
buffer[ret] = '\0';
87+
8288
// Find 200 OK HTTP status in reply
8389
bool found_200_ok = find_substring(buffer, buffer + ret, HTTP_OK_STR, HTTP_OK_STR + strlen(HTTP_OK_STR));
8490
// Find "Hello World!" string in reply

0 commit comments

Comments
 (0)