@@ -67,16 +67,17 @@ bool find_substring(const char *first, const char *last, const char *s_first, co
67
67
void get_data (TCPSocket* sock){
68
68
bool result = false ;
69
69
// Server will respond with HTTP GET's success code
70
- const int ret = sock->recv (buffer, sizeof (buffer) - 1 );
71
- if (ret <= 0 )
72
- return ;
73
-
74
- buffer[ret] = ' \0 ' ;
70
+ int len = 0 ;
71
+ int ret;
72
+ while ((ret = sock->recv (buffer+len, sizeof (buffer) - 1 - len)) > 0 ) {
73
+ len += ret;
74
+ }
75
+ buffer[len] = ' \0 ' ;
75
76
76
77
// Find 200 OK HTTP status in reply
77
- bool found_200_ok = find_substring (buffer, buffer + ret , HTTP_OK_STR, HTTP_OK_STR + strlen (HTTP_OK_STR));
78
+ bool found_200_ok = find_substring (buffer, buffer + len , HTTP_OK_STR, HTTP_OK_STR + strlen (HTTP_OK_STR));
78
79
// Find "Hello World!" string in reply
79
- bool found_hello = find_substring (buffer, buffer + ret , HTTP_HELLO_STR, HTTP_HELLO_STR + strlen (HTTP_HELLO_STR));
80
+ bool found_hello = find_substring (buffer, buffer + len , HTTP_HELLO_STR, HTTP_HELLO_STR + strlen (HTTP_HELLO_STR));
80
81
81
82
TEST_ASSERT_TRUE (found_200_ok);
82
83
TEST_ASSERT_TRUE (found_hello);
@@ -85,7 +86,7 @@ void get_data(TCPSocket* sock){
85
86
86
87
TEST_ASSERT_EQUAL (result, true );
87
88
88
- printf (" HTTP: Received %d chars from server\r\n " , ret );
89
+ printf (" HTTP: Received %d chars from server\r\n " , len );
89
90
printf (" HTTP: Received 200 OK status ... %s\r\n " , found_200_ok ? " [OK]" : " [FAIL]" );
90
91
printf (" HTTP: Received '%s' status ... %s\r\n " , HTTP_HELLO_STR, found_hello ? " [OK]" : " [FAIL]" );
91
92
printf (" HTTP: Received message:\r\n " );
@@ -109,7 +110,7 @@ void test_socket_attach() {
109
110
110
111
// Dispatch event queue
111
112
Thread eventThread;
112
- EventQueue queue (4 *EVENTS_EVENT_SIZE);
113
+ EventQueue queue (10 *EVENTS_EVENT_SIZE);
113
114
eventThread.start (callback (&queue, &EventQueue::dispatch_forever));
114
115
115
116
printf (" TCP client IP Address is %s\r\n " , net->get_ip_address ());
0 commit comments