Simple usage example HTTPClient with wolfSSL

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed wolfSSL

Fork of SimpleHTTPSClient by wolf SSL

Files at this revision

API Documentation at this revision

Comitter:
wolfSSL
Date:
Mon Dec 08 12:08:05 2014 +0000
Child:
1:54bce95d1d97
Commit message:
Initial version

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Mon Dec 08 12:08:05 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/wolfSSL/code/EthernetInterface/#a477218b744e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Mon Dec 08 12:08:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/wolfSSL/code/HTTPClient/#a9ecee69c6b5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 08 12:08:05 2014 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "HTTPClient.h"
+
+#define SERVER_URL      "http://192.168.1.12/574d76fcb/keys.txt"
+#define SERVER_URL_SSL "https://192.168.1.12/574d76fcb/keys.txt"
+
+EthernetInterface eth;
+HTTPClient http;
+char recvBuff[1024*20];
+
+int main()
+{
+    int ret ;
+
+    eth.init(); //Use DHCP
+    printf("HTTP Client, Starting,...\n") ;
+    while(1) {
+        if(eth.connect() == 0)break ;
+        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));
+    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));
+    if (!ret) {
+        printf("Result: %s\n", recvBuff);
+    } else {
+        printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+    }
+    
+    eth.disconnect();
+    while(1) {
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Dec 08 12:08:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#f1ef95efa5ad
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 08 12:08:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file