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:
29:383e9bfbfbed
Parent:
23:15fa2726f793
Child:
32:fa4d71265625
--- a/source/http_request.h	Tue Mar 27 11:07:02 2018 +0200
+++ b/source/http_request.h	Fri Aug 10 11:30:37 2018 +0100
@@ -51,7 +51,7 @@
                                 If not set, the complete body will be allocated on the HttpResponse object,
                                 which might use lots of memory.
     */
-    HttpRequest(NetworkInterface* aNetwork, http_method aMethod, const char* url, Callback<void(const char *at, size_t length)> aBodyCallback = 0)
+    HttpRequest(NetworkInterface* aNetwork, http_method aMethod, const char* url, Callback<void(const char *at, uint32_t length)> aBodyCallback = 0)
         : network(aNetwork), method(aMethod), body_callback(aBodyCallback)
     {
         error = 0;
@@ -74,7 +74,7 @@
                                 If not set, the complete body will be allocated on the HttpResponse object,
                                 which might use lots of memory.
     */
-    HttpRequest(TCPSocket* aSocket, http_method aMethod, const char* url, Callback<void(const char *at, size_t length)> aBodyCallback = 0)
+    HttpRequest(TCPSocket* aSocket, http_method aMethod, const char* url, Callback<void(const char *at, uint32_t length)> aBodyCallback = 0)
         : socket(aSocket), method(aMethod), body_callback(aBodyCallback)
     {
         error = 0;
@@ -126,7 +126,7 @@
             return NULL;
         }
 
-        size_t request_size = 0;
+        uint32_t request_size = 0;
         char* request = request_builder->build(body, body_size, request_size);
 
         ret = send_buffer(request, request_size);
@@ -148,7 +148,7 @@
      * @return An HttpResponse pointer on success, or NULL on failure.
      *         See get_error() for the error code.
      */
-    HttpResponse* send(Callback<const void*(size_t*)> body_cb) {
+    HttpResponse* send(Callback<const void*(uint32_t*)> body_cb) {
 
         nsapi_error_t ret;
 
@@ -159,7 +159,7 @@
 
         set_header("Transfer-Encoding", "chunked");
 
-        size_t request_size = 0;
+        uint32_t request_size = 0;
         char* request = request_builder->build(NULL, 0, request_size);
 
         // first... send this request headers without the body
@@ -173,14 +173,14 @@
 
         // ok... now it's time to start sending chunks...
         while (1) {
-            size_t size;
+            uint32_t size;
             const void *buffer = body_cb(&size);
 
             if (size == 0) break;
 
             // so... size in HEX, \r\n, data, \r\n again
             char size_buff[10]; // if sending length of more than 8 digits, you have another problem on a microcontroller...
-            size_t size_buff_size = sprintf(size_buff, "%X\r\n", size);
+            uint32_t size_buff_size = sprintf(size_buff, "%X\r\n", size);
             if ((total_send_count = send_buffer(size_buff, size_buff_size)) < 0) {
                 free(request);
                 error = total_send_count;
@@ -262,7 +262,7 @@
         return NSAPI_ERROR_OK;
     }
 
-    nsapi_size_or_error_t send_buffer(char* buffer, size_t buffer_size) {
+    nsapi_size_or_error_t send_buffer(char* buffer, uint32_t buffer_size) {
         nsapi_size_or_error_t total_send_count = 0;
         while (total_send_count < buffer_size) {
             nsapi_size_or_error_t send_result = socket->send(buffer + total_send_count, buffer_size - total_send_count);
@@ -296,7 +296,7 @@
         while ((recv_ret = socket->recv(recv_buffer, HTTP_RECEIVE_BUFFER_SIZE)) > 0) {
 
             // Pass the chunk into the http_parser
-            size_t nparsed = parser.execute((const char*)recv_buffer, recv_ret);
+            uint32_t nparsed = parser.execute((const char*)recv_buffer, recv_ret);
             if (nparsed != recv_ret) {
                 // printf("Parsing failed... parsed %d bytes, received %d bytes\n", nparsed, recv_ret);
                 error = -2101;
@@ -333,7 +333,7 @@
     NetworkInterface* network;
     TCPSocket* socket;
     http_method method;
-    Callback<void(const char *at, size_t length)> body_callback;
+    Callback<void(const char *at, uint32_t length)> body_callback;
 
     ParsedUrl* parsed_url;