Simple HTTPS access example with HTTPClient class

Dependencies:   EthernetInterface-FRDM HTTPClient mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
wolfSSL
Date:
Sat Feb 07 19:12:32 2015 +0000
Parent:
2:071a8275fa40
Child:
4:68c5a3f49a48
Commit message:
Code cleaned

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Mon Dec 08 22:26:51 2014 +0000
+++ b/EthernetInterface.lib	Sat Feb 07 19:12:32 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/wolfSSL/code/EthernetInterface/#a477218b744e
+http://developer.mbed.org/users/wolfSSL/code/EthernetInterface-FRDM/#4c9bfb661297
--- a/main.cpp	Mon Dec 08 22:26:51 2014 +0000
+++ b/main.cpp	Sat Feb 07 19:12:32 2015 +0000
@@ -2,13 +2,20 @@
 #include "EthernetInterface.h"
 #include "HTTPClient.h"
 
-#define SERVER_URL      "http://192.168.49.57/574d76fcb/keys.txt"
-#define SERVER_URL_SSL "https://192.168.49.57/574d76fcb/keys.txt"
-
 EthernetInterface eth;
 HTTPClient http;
 char recvBuff[1024*20];
 
+void getline(char *line, int size) {
+    for(int i=0; i<size; i++) {
+        if((line[i] = getchar()) == '\r') {
+            line[i] = '\0' ;
+            putchar('\n') ;
+            break ;
+        } else putchar(line[i]) ;
+    }
+}
+
 void net_main(void const *av)
 {
     int ret ;
@@ -20,22 +27,18 @@
         printf("Retry\n") ;
     }
     
-    printf("HTTP Client, IP Address is %s\n", eth.getIPAddress());
-    
     /*** HTTP ***/
-    printf("\nFetching... %s\n", SERVER_URL);
-    ret = http.get(SERVER_URL, recvBuff, sizeof(recvBuff));
+    printf("\nFetching HTTP\n");
+    ret = http.get("http://192.168.1.12/574d76fcb/keys.txt", recvBuff, sizeof(recvBuff));
     if (!ret) {
         printf("Result: %s\n", recvBuff);
     } else {
         printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
     }
     
-    wait(5.0) ;
-    
     /*** HTTPS (SSL) ***/
-    printf("\nFetching... %s\n", SERVER_URL_SSL);
-    ret = http.get(SERVER_URL_SSL, recvBuff, sizeof(recvBuff));
+    printf("\nFetching HTTPS\n");
+    ret = http.get("https://192.168.1.12/574d76fcb/keys.txt", recvBuff, sizeof(recvBuff));
     if (!ret) {
         printf("Result: %s\n", recvBuff);
     } else {
@@ -56,4 +59,4 @@
     while (true) {
         Thread::wait(1000);
     }
-}
\ No newline at end of file
+}
--- a/mbed-rtos.lib	Mon Dec 08 22:26:51 2014 +0000
+++ b/mbed-rtos.lib	Sat Feb 07 19:12:32 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#f1ef95efa5ad
+http://mbed.org/users/mbed_official/code/mbed-rtos/#5448826aa700
--- a/mbed.bld	Mon Dec 08 22:26:51 2014 +0000
+++ b/mbed.bld	Sat Feb 07 19:12:32 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/e188a91d3eaa
\ No newline at end of file