Microsoft Azure IoTHub client HTTP transport

Dependents:   iothub_client_sample_http simplesample_http temp_sensor_anomaly

This library implements the HTTP transport for Microsoft Azure IoTHub client. The code is replicated from https://github.com/Azure/azure-iot-sdks

Revision:
2:ff9104b866b8
Parent:
1:2ba812f3d9b7
Child:
3:4e9296134ffb
--- a/iothubtransporthttp.c	Tue Sep 15 22:25:44 2015 -0700
+++ b/iothubtransporthttp.c	Wed Sep 16 22:42:49 2015 -0700
@@ -22,7 +22,6 @@
 #include "httpheaders.h"
 #include "agenttime.h"
 
-
 #define IOTHUB_APP_PREFIX "iothub-app-"
 
 #define CONTENT_TYPE "Content-Type"
@@ -33,6 +32,8 @@
 /*the default is 25 minutes*/
 #define DEFAULT_GETMINIMUMPOLLINGTIME ((unsigned int)25*60) 
 
+#define MAXIMUM_MESSAGE_SIZE (255*1024-1)
+
 /*forward declaration*/
 static int appendMapToJSON(STRING_HANDLE existing, const char* const* keys, const char* const* values, size_t count);
 
@@ -816,8 +817,8 @@
                 }
                 else
                 {
-                    /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_071: [If the oldest message in waitingToSend causes the message to exceed 256K bytes then it shall be removed from waitingToSend, and IoTHubClient_LL_SendComplete shall be called. Parameter PDLIST_ENTRY completed shall point to a list containing only the oldest item, and parameter IOTHUB_BATCHSTATE result shall be set to IOTHUB_BATCHSTATE_FAILED.] */
-                    if (STRING_length(temp) >= 256 * 1024)
+                    /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_071: [If the oldest message in waitingToSend causes the message size to exceed the message size limit then it shall be removed from waitingToSend, and IoTHubClient_LL_SendComplete shall be called. Parameter PDLIST_ENTRY completed shall point to a list containing only the oldest item, and parameter IOTHUB_BATCHSTATE result shall be set to IOTHUB_BATCHSTATE_FAILED.]*/
+                    if (STRING_length(temp) >= MAXIMUM_MESSAGE_SIZE)
                     {
                         PDLIST_ENTRY head = DList_RemoveHeadList(handleData->waitingToSend); /*actually this is the same as "actual", but now it is removed*/
                         DList_InsertTailList(&(handleData->eventConfirmations), head);
@@ -858,7 +859,7 @@
                 }
                 else
                 {
-                    if (STRING_length(*payload) + STRING_length(temp) > 256 * 1024)
+                    if (STRING_length(*payload) + STRING_length(temp) > MAXIMUM_MESSAGE_SIZE)
                     {
                         /*this item doesn't make it to the payload, but the payload is valid so far*/
                         /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_072: [If at any point during construction of the string there are errors, IoTHubTransportHttp_DoWork shall use the so far constructed string as payload.]*/
@@ -1035,8 +1036,8 @@
             }
             else
             {
-                /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_109: [If the oldest message in waitingToSend causes the message to exceed 256K bytes then it shall be removed from waitingToSend, and IoTHubClient_LL_SendComplete shall be called. Parameter PDLIST_ENTRY completed shall point to a list containing only the oldest item, and parameter IOTHUB_BATCHSTATE result shall be set to IOTHUB_BATCHSTATE_FAILED.] */
-                if (messageSize >= 256 * 1024)
+                /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_109: [If the oldest message in waitingToSend causes the message to exceed the message size limit then it shall be removed from waitingToSend, and IoTHubClient_LL_SendComplete shall be called. Parameter PDLIST_ENTRY completed shall point to a list containing only the oldest item, and parameter IOTHUB_BATCHSTATE result shall be set to IOTHUB_BATCHSTATE_FAILED.]*/
+                if (messageSize >= MAXIMUM_MESSAGE_SIZE)
                 {
                     PDLIST_ENTRY head = DList_RemoveHeadList(handleData->waitingToSend); /*actually this is the same as "actual", but now it is removed*/
                     DList_InsertTailList(&(handleData->eventConfirmations), head);