Fork of SandBox's original mbed-http (https://os.mbed.com/teams/sandbox/code/mbed-http/) and update for MbedOS6+ Content of TESTS folder was replaced with basic examples form original SandBox's HelloWorld

Revision:
36:d46da03715db
Parent:
32:fa4d71265625
Child:
37:98d83ca14b7b
diff -r b3ee394d1d2e -r d46da03715db source/https_request.h
--- a/source/https_request.h	Fri Aug 09 09:58:57 2019 +0200
+++ b/source/https_request.h	Fri Aug 09 10:36:07 2019 +0200
@@ -87,6 +87,60 @@
         _we_created_socket = false;
     }
 
+    /**
+     * HttpsRequest Constructor
+     * Initializes the TCP socket, sets up event handlers and flags.
+     *
+     * @param[in] network The network interface
+     * @param[in] ssl_ca_pem String containing the trusted CAs
+     * @param[in] method HTTP method to use
+     * @param[in] url Parsed URL
+     * @param[in] body_callback Callback on which to retrieve chunks of the response body.
+                                If not set, the complete body will be allocated on the HttpResponse object,
+                                which might use lots of memory.
+     */
+    HttpsRequest(NetworkInterface* network,
+                 const char* ssl_ca_pem,
+                 http_method method,
+                 ParsedUrl* url,
+                 Callback<void(const char *at, uint32_t length)> body_callback = 0)
+        : HttpRequestBase(NULL, body_callback)
+    {
+        _parsed_url = url;
+        _request_builder = new HttpRequestBuilder(method, _parsed_url);
+        _response = NULL;
+
+        _socket = new TLSSocket();
+        ((TLSSocket*)_socket)->open(network);
+        ((TLSSocket*)_socket)->set_root_ca_cert(ssl_ca_pem);
+        _we_created_socket = true;
+    }
+
+    /**
+     * HttpsRequest Constructor
+     * Sets up event handlers and flags.
+     *
+     * @param[in] socket A connected TLSSocket
+     * @param[in] method HTTP method to use
+     * @param[in] url Parsed URL
+     * @param[in] body_callback Callback on which to retrieve chunks of the response body.
+                                If not set, the complete body will be allocated on the HttpResponse object,
+                                which might use lots of memory.
+     */
+    HttpsRequest(TLSSocket* socket,
+                 http_method method,
+                 ParsedUrl* url,
+                 Callback<void(const char *at, uint32_t length)> body_callback = 0)
+        : HttpRequestBase(socket, body_callback)
+    {
+        _parsed_url = url;
+        _body_callback = body_callback;
+        _request_builder = new HttpRequestBuilder(method, _parsed_url);
+        _response = NULL;
+
+        _we_created_socket = false;
+    }
+
     virtual ~HttpsRequest() {}
 
 protected: