@@ -35,15 +35,16 @@ bool find_substring(const char *first, const char *last, const char *s_first, co
35
35
int main () {
36
36
GREENTEA_SETUP (20 , " default_auto" );
37
37
38
- bool result = true ;
38
+ bool result = false ;
39
39
EthernetInterface eth;
40
40
// eth.init(); //Use DHCP
41
41
eth.connect ();
42
42
printf (" TCP client IP Address is %s\r\n " , eth.get_ip_address ());
43
43
44
44
TCPSocket sock (ð);
45
+ printf (" HTTP: Connection to %s:%d\r\n " , HTTP_SERVER_NAME, HTTP_SERVER_PORT);
45
46
if (sock.connect (HTTP_SERVER_NAME, HTTP_SERVER_PORT) == 0 ) {
46
- printf (" HTTP: Connected to %s:%d \r\n " , HTTP_SERVER_NAME, HTTP_SERVER_PORT );
47
+ printf (" HTTP: OK \r\n " );
47
48
48
49
// We are constructing GET command like this:
49
50
// GET http://developer.mbed.org/media/uploads/mbed_official/hello.txt HTTP/1.0\n\n
@@ -66,17 +67,18 @@ int main() {
66
67
TEST_ASSERT_TRUE (found_200_ok);
67
68
TEST_ASSERT_TRUE (found_hello);
68
69
69
- if (!found_200_ok) result = false ;
70
- if (!found_hello) result = false ;
70
+ if (found_200_ok && found_hello) result = true ;
71
71
72
72
printf (" HTTP: Received %d chars from server\r\n " , ret);
73
73
printf (" HTTP: Received 200 OK status ... %s\r\n " , found_200_ok ? " [OK]" : " [FAIL]" );
74
74
printf (" HTTP: Received '%s' status ... %s\r\n " , HTTP_HELLO_STR, found_hello ? " [OK]" : " [FAIL]" );
75
- printf (" HTTP: Received massage: \r\n \r\n" );
75
+ printf (" HTTP: Received message: \r\n " );
76
76
printf (" %s" , buffer);
77
+ sock.close ();
78
+ } else {
79
+ printf (" HTTP: ERROR\r\n " );
77
80
}
78
81
79
- sock.close ();
80
82
eth.disconnect ();
81
83
GREENTEA_TESTSUITE_RESULT (result);
82
84
}
0 commit comments