HTTP/HTTPS Client Library for the X-NUCLEO-IDW01M1v2 wifi board.

Dependents:   HTTPClient_HelloWorld_IDW01M1 wifigianluigi HTTPClient_HelloWorld_IDW01M1_Fabio_Ricezione

Fork of HTTPClient by ST Expansion SW Team

Files at this revision

API Documentation at this revision

Comitter:
mapellil
Date:
Fri Jan 13 14:40:02 2017 +0000
Parent:
23:1a0d4d70f72c
Commit message:
Added HTTPS support

Changed in this revision

HTTPClient.cpp Show annotated file Show diff for this revision Revisions of this file
HTTPClient.h Show annotated file Show diff for this revision Revisions of this file
diff -r 1a0d4d70f72c -r dafc02922e40 HTTPClient.cpp
--- a/HTTPClient.cpp	Mon Dec 05 16:20:48 2016 +0000
+++ b/HTTPClient.cpp	Fri Jan 13 14:40:02 2017 +0000
@@ -18,7 +18,7 @@
  */
 
 //Debug is disabled by default
-#if 1
+#if 0
 //Enable debug
 #include <cstdio>
 #define DBG(x, ...) std::printf("[HTTPClient : DBG]"x"\r\n", ##__VA_ARGS__); 
@@ -47,7 +47,8 @@
 #include <cstring>
 #include "HTTPClient.h"
 
-HTTPClient::HTTPClient(NetworkStack  & _m_intf) : m_intf(_m_intf)
+//HTTPClient::HTTPClient(NetworkStack  & _m_intf) : m_intf(_m_intf)
+HTTPClient::HTTPClient(SpwfSAInterface  & _m_intf) : m_intf(_m_intf)
 {    
 }
 
@@ -136,17 +137,22 @@
     return res;
   }
 
+  if ((strcmp ("https", scheme)) == 0 || (strcmp ("HTTPS", scheme) == 0)) {
+      if ( port == 0) port = 443;     
+      m_intf.set_secure_mode(); 
+  }
   if(port == 0) //TODO do handle HTTPS->443
   {
     port = 80;
   }
-
+  
   DBG("Scheme: %s", scheme);
   DBG("Host: %s", host);
   DBG("Port: %d", port);
   DBG("Path: %s", path);
 // Open
   m_sock.open(&m_intf);
+  m_intf.set_unsecure_mode();  
   //Connect
   DBG("Connecting socket to server");
   int ret = m_sock.connect(host, port);
diff -r 1a0d4d70f72c -r dafc02922e40 HTTPClient.h
--- a/HTTPClient.h	Mon Dec 05 16:20:48 2016 +0000
+++ b/HTTPClient.h	Fri Jan 13 14:40:02 2017 +0000
@@ -63,7 +63,8 @@
 {
 public:
   ///Instantiate the HTTP client
-  HTTPClient(NetworkStack & _m_intf);      
+//  HTTPClient(NetworkStack & _m_intf);      
+  HTTPClient(SpwfSAInterface & _m_intf);      
 
   ~HTTPClient();
   
@@ -148,7 +149,8 @@
   HTTPResult parseURL(const char* url, char* scheme, size_t maxSchemeLen, char* host, size_t maxHostLen, uint16_t* port, char* path, size_t maxPathLen); //Parse URL
 
   //Parameters 
-  NetworkStack & m_intf;  // WiFi interface
+ // NetworkStack & m_intf;  // WiFi interface
+  SpwfSAInterface & m_intf;  // WiFi interface
   TCPSocket  m_sock;         // TCP socket
 
   int m_timeout;