From a22d968996c1b87a97527e5e743a8e0be74e7e50 Mon Sep 17 00:00:00 2001 From: Senthil Ramakrishnan Date: Mon, 8 Jan 2018 14:14:01 -0600 Subject: [PATCH] Fix tcp_hello_world test to receive all the data from http response --- TESTS/netsocket/tcp_hello_world/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/TESTS/netsocket/tcp_hello_world/main.cpp b/TESTS/netsocket/tcp_hello_world/main.cpp index 155e5fca29..b6e36dd538 100644 --- a/TESTS/netsocket/tcp_hello_world/main.cpp +++ b/TESTS/netsocket/tcp_hello_world/main.cpp @@ -76,9 +76,15 @@ void test_tcp_hello_world() { sock.send(buffer, strlen(buffer)); // Server will respond with HTTP GET's success code - const int ret = sock.recv(buffer, sizeof(buffer) - 1); - buffer[ret] = '\0'; + int ret = 0; + int bytes_recvd = 0; + do { + ret += bytes_recvd; + bytes_recvd = sock.recv(buffer+ret, sizeof(buffer) - 1 - ret); + }while(bytes_recvd > 0); + buffer[ret] = '\0'; + // Find 200 OK HTTP status in reply bool found_200_ok = find_substring(buffer, buffer + ret, HTTP_OK_STR, HTTP_OK_STR + strlen(HTTP_OK_STR)); // Find "Hello World!" string in reply