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
Diff: iothubtransporthttp.c
- Revision:
- 12:9e2531d86009
- Parent:
- 11:495deb847d9c
- Child:
- 13:848d52f93daf
--- a/iothubtransporthttp.c Thu Jan 28 12:38:29 2016 -0800 +++ b/iothubtransporthttp.c Thu Feb 04 11:28:24 2016 -0800 @@ -79,14 +79,14 @@ }HTTPTRANSPORT_HANDLE_DATA; -/*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_003: [Otherwise IoTHubTransportHttp_Create shall create an immutable string (further called "event HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/events?api-version=2015-08-15-preview".]*/ +/*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_003: [Otherwise IoTHubTransportHttp_Create shall create an immutable string (further called "event HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/events?api-version=2016-02-03".]*/ static void destroy_eventHTTPrelativePath(HTTPTRANSPORT_HANDLE_DATA* handleData) { STRING_delete(handleData->eventHTTPrelativePath); handleData->eventHTTPrelativePath = NULL; } -/*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_003: [Otherwise IoTHubTransportHttp_Create shall create an immutable string (further called "event HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/events?api-version=2015-08-15-preview".]*/ +/*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_003: [Otherwise IoTHubTransportHttp_Create shall create an immutable string (further called "event HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/events?api-version=2016-02-03".]*/ static bool create_eventHTTPrelativePath(HTTPTRANSPORT_HANDLE_DATA* handleData, const IOTHUBTRANSPORT_CONFIG* config) { bool result; @@ -113,14 +113,14 @@ return result; } -/*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_034: [Otherwise, IoTHubTransportHttp_Create shall create an immutable string (further called "message HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/devicebound?api-version=2015-08-15-preview".]*/ +/*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_034: [Otherwise, IoTHubTransportHttp_Create shall create an immutable string (further called "message HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/devicebound?api-version=2016-02-03".]*/ static void destroy_messageHTTPrelativePath(HTTPTRANSPORT_HANDLE_DATA* handleData) { STRING_delete(handleData->messageHTTPrelativePath); handleData->messageHTTPrelativePath = NULL; } -/*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_034: [Otherwise, IoTHubTransportHttp_Create shall create an immutable string (further called "message HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/devicebound?api-version=2015-08-15-preview".]*/ +/*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_034: [Otherwise, IoTHubTransportHttp_Create shall create an immutable string (further called "message HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/devicebound?api-version=2016-02-03".]*/ static bool create_messageHTTPrelativePath(HTTPTRANSPORT_HANDLE_DATA* handleData, const IOTHUBTRANSPORT_CONFIG* config) { bool result; @@ -169,7 +169,7 @@ "Content-Type":"application/vnd.microsoft.iothub.json" "Accept":"application/json" "Connection":"Keep-Alive" -"User-Agent":"iothubclient1.0.0-preview.7]*/ +"User-Agent":"iothubclient1.0.0]*/ static bool create_eventHTTPrequestHeaders(HTTPTRANSPORT_HANDLE_DATA* handleData, const IOTHUBTRANSPORT_CONFIG* config) { bool result; @@ -470,7 +470,7 @@ } else { - /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_003: [Otherwise IoTHubTransportHttp_Create shall create an immutable string (further called "event HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/events?api-version=2015-08-15-preview".]*/ + /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_003: [Otherwise IoTHubTransportHttp_Create shall create an immutable string (further called "event HTTP relative path") from the following pieces: "/devices/" + URL_ENCODED(config->upperConfig->deviceId) + "/messages/events?api-version=2016-02-03".]*/ result = (HTTPTRANSPORT_HANDLE_DATA*)malloc(sizeof(HTTPTRANSPORT_HANDLE_DATA)); if (result == NULL) { @@ -1250,7 +1250,7 @@ { /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_050: [_DoWork shall call HTTPAPIEX_SAS_ExecuteRequest with the following parameters: -requestType: POST --relativePath: abandon relative path begin (as created by _Create) + value of ETag + "/abandon?api-version=2015-08-15-preview" +-relativePath: abandon relative path begin (as created by _Create) + value of ETag + "/abandon?api-version=2016-02-03" - requestHttpHeadersHandle: an HTTP headers instance containing the following Authorization: " " If-Match: value of ETag @@ -1260,7 +1260,7 @@ - responseContent: NULL]*/ /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_051: [_DoWork shall call HTTPAPIEX_SAS_ExecuteRequest with the following parameters: -requestType: DELETE --relativePath: abandon relative path begin + value of ETag + "?api-version=2015-08-15-preview" +-relativePath: abandon relative path begin + value of ETag + "?api-version=2016-02-03" - requestHttpHeadersHandle: an HTTP headers instance containing the following Authorization: " " If-Match: value of ETag @@ -1270,7 +1270,7 @@ - responseContent: NULL]*/ /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_077: [_DoWork shall call HTTPAPIEX_SAS_ExecuteRequest with the following parameters: -requestType: DELETE --relativePath: abandon relative path begin + value of ETag +"?api-version=2015-08-15-preview" + "&reject" +-relativePath: abandon relative path begin + value of ETag +"?api-version=2016-02-03" + "&reject" - requestHttpHeadersHandle: an HTTP headers instance containing the following Authorization: " " If-Match: value of ETag @@ -1338,7 +1338,7 @@ handleData->sasObject, handleData->httpApiExHandle, (action == ABANDON) ? HTTPAPI_REQUEST_POST : HTTPAPI_REQUEST_DELETE, /*-requestType: POST */ - STRING_c_str(fullAbandonRelativePath), /*-relativePath: abandon relative path begin (as created by _Create) + value of ETag + "/abandon?api-version=2015-08-15-preview" */ + STRING_c_str(fullAbandonRelativePath), /*-relativePath: abandon relative path begin (as created by _Create) + value of ETag + "/abandon?api-version=2016-02-03" */ abandonRequestHttpHeaders, /*- requestHttpHeadersHandle: an HTTP headers instance containing the following */ NULL, /*- requestContent: NULL */ &statusCode, /*- statusCode: a pointer to unsigned int which might be examined for logging */