Azure IoT common library
Dependents: STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more
Diff: httpapiex.c
- Revision:
- 21:b92006c5b9ff
- Parent:
- 19:2e0811512ceb
- Child:
- 25:8507bf644fdf
--- a/httpapiex.c Fri Feb 10 17:01:36 2017 -0800 +++ b/httpapiex.c Fri Feb 24 14:01:41 2017 -0800 @@ -4,6 +4,7 @@ #include <stdlib.h> #include "azure_c_shared_utility/gballoc.h" #include "azure_c_shared_utility/httpapiex.h" +#include "azure_c_shared_utility/optimize_size.h" #include "azure_c_shared_utility/xlogging.h" #include "azure_c_shared_utility/strings.h" #include "azure_c_shared_utility/crt_abstractions.h" @@ -103,7 +104,7 @@ if (*toBeUsedRequestHttpHeadersHandle == NULL) { - result = __LINE__; + result = __FAILURE__; LogError("unable to HTTPHeaders_Alloc"); } else @@ -128,7 +129,7 @@ HTTPHeaders_Free(*toBeUsedRequestHttpHeadersHandle); } *toBeUsedRequestHttpHeadersHandle = NULL; - result = __LINE__; + result = __FAILURE__; } else { @@ -145,7 +146,7 @@ { if ((*toBeUsedResponsetHttpHeadersHandle = HTTPHeaders_Alloc()) == NULL) { - result = __LINE__; + result = __FAILURE__; } else { @@ -171,7 +172,7 @@ *toBeUsedRequestContent = BUFFER_new(); if (*toBeUsedRequestContent == NULL) { - result = __LINE__; + result = __FAILURE__; } else { @@ -207,20 +208,20 @@ /*Codes_SRS_HTTPAPIEX_02_014: [If requestContent is not NULL then its content and its size shall be used for parameters content and contentLength of HTTPAPI_ExecuteRequest.] */ if (buildBufferIfNotExist(requestContent, isOriginalRequestContent, toBeUsedRequestContent) != 0) { - result = __LINE__; LogError("unable to build the request content"); + result = __FAILURE__; } else { if (buildRequestHttpHeadersHandle(handle, *toBeUsedRequestContent, requestHttpHeadersHandle, isOriginalRequestHttpHeadersHandle, toBeUsedRequestHttpHeadersHandle) != 0) { /*Codes_SRS_HTTPAPIEX_02_010: [If any of the operations in SRS_HTTAPIEX_02_009 fails, then HTTPAPIEX_ExecuteRequest shall return HTTPAPIEX_ERROR.] */ - result = __LINE__; if (*isOriginalRequestContent == false) { BUFFER_delete(*toBeUsedRequestContent); } LogError("unable to build the request http headers handle"); + result = __FAILURE__; } else { @@ -250,7 +251,6 @@ if (buildResponseHttpHeadersHandle(responseHttpHeadersHandle, isOriginalResponseHttpHeadersHandle, toBeUsedResponseHttpHeadersHandle) != 0) { /*Codes_SRS_HTTPAPIEX_02_018: [If creating the temporary http headers in SRS_HTTPAPIEX_02_017 fails then HTTPAPIEX_ExecuteRequest shall return HTTPAPIEX_ERROR.] */ - result = __LINE__; if (*isOriginalRequestContent == false) { BUFFER_delete(*toBeUsedRequestContent); @@ -260,6 +260,7 @@ HTTPHeaders_Free(*toBeUsedRequestHttpHeadersHandle); } LogError("unable to build response content"); + result = __FAILURE__; } else { @@ -268,7 +269,6 @@ if (buildBufferIfNotExist(responseContent, isOriginalResponseContent, toBeUsedResponseContent) != 0) { /*Codes_SRS_HTTPAPIEX_02_021: [If creating the BUFFER_HANDLE in SRS_HTTPAPIEX_02_020 fails, then HTTPAPIEX_ExecuteRequest shall return HTTPAPIEX_ERROR.] */ - result = __LINE__; if (*isOriginalRequestContent == false) { BUFFER_delete(*toBeUsedRequestContent); @@ -282,6 +282,7 @@ HTTPHeaders_Free(*toBeUsedResponseHttpHeadersHandle); } LogError("unable to build response content"); + result = __FAILURE__; } else { @@ -556,7 +557,7 @@ if (mallocAndStrcpy_s((char**)&(newOption.optionName), optionName) != 0) { free((void*)value); - result = __LINE__; + result = __FAILURE__; } else { @@ -566,7 +567,7 @@ LogError("unable to VECTOR_push_back"); free((void*)newOption.optionName); free((void*)value); - result = __LINE__; + result = __FAILURE__; } else {