httpapi.h

This module implements the standard HTTP API used by the C IoT client library.

Includes

#include <stddef.h>
#include "azure_macro_utils/macro_utils.h"
#include "azure_c_shared_utility/httpheaders.h"
#include "azure_c_shared_utility/buffer_.h"
#include "umock_c/umock_c_prod.h"

Detailed Description

For example, on the Windows platform the HTTP API code uses WinHTTP and for Linux it uses curl and so forth. HTTPAPI must support HTTPs (HTTP+SSL).

Functions

Function Name Description
HTTPAPI_RESULTStrings
HTTPAPI_RESULT_FromString
HTTPAPI_REQUEST_TYPEStrings
HTTPAPI_REQUEST_TYPE_FromString
HTTPAPI_Init Global initialization for the HTTP API component.
HTTPAPI_Deinit Free resources allocated in HTTPAPI_Init.
HTTPAPI_CreateConnection Creates an HTTPS connection to the host specified by the hostName parameter.
HTTPAPI_CloseConnection Closes a connection created with HTTPAPI_CreateConnection.
HTTPAPI_ExecuteRequest Sends the HTTP request to the host and handles the response for the HTTP call.
HTTPAPI_SetOption Sets the option named optionName bearing the value value for the HTTP_HANDLE handle.
HTTPAPI_CloneOption Clones the option named optionName bearing the value value into the pointer savedValue.

Macro definitions

AMBIGUOUS_STATUS_CODE

#define AMBIGUOUS_STATUS_CODE  (300) 

HTTPAPI_RESULT_VALUES

#define HTTPAPI_RESULT_VALUES \
        HTTPAPI_OK, \
        HTTPAPI_INVALID_ARG, \
        HTTPAPI_ERROR, \
        HTTPAPI_OPEN_REQUEST_FAILED, \
        HTTPAPI_SET_OPTION_FAILED, \
        HTTPAPI_SEND_REQUEST_FAILED, \
        HTTPAPI_RECEIVE_RESPONSE_FAILED, \
        HTTPAPI_QUERY_HEADERS_FAILED, \
        HTTPAPI_QUERY_DATA_AVAILABLE_FAILED, \
        HTTPAPI_READ_DATA_FAILED, \
        HTTPAPI_ALREADY_INIT, \
        HTTPAPI_NOT_INIT, \
        HTTPAPI_HTTP_HEADERS_FAILED, \
        HTTPAPI_STRING_PROCESSING_ERROR, \
        HTTPAPI_ALLOC_FAILED, \
        HTTPAPI_INIT_FAILED, \
        HTTPAPI_INSUFFICIENT_RESPONSE_BUFFER, \
        HTTPAPI_SET_X509_FAILURE, \
        HTTPAPI_SET_TIMEOUTS_FAILED 

HTTPAPI_REQUEST_TYPE_VALUES

#define HTTPAPI_REQUEST_TYPE_VALUES \
        HTTPAPI_REQUEST_GET, \
        HTTPAPI_REQUEST_POST, \
        HTTPAPI_REQUEST_PUT, \
        HTTPAPI_REQUEST_DELETE, \
        HTTPAPI_REQUEST_PATCH, \
        HTTPAPI_REQUEST_HEAD 

MAX_HOSTNAME_LEN

#define MAX_HOSTNAME_LEN  65 

MAX_USERNAME_LEN

#define MAX_USERNAME_LEN  65 

MAX_PASSWORD_LEN

#define MAX_PASSWORD_LEN  65 

Enumeration types

HTTPAPI_RESULT

Enumeration specifying the possible return values for the APIs in this module.

enum HTTPAPI_RESULT {
  HTTPAPI_RESULT_INVALID,
  HTTPAPI_OK,
  HTTPAPI_INVALID_ARG,
  HTTPAPI_ERROR,
  HTTPAPI_OPEN_REQUEST_FAILED,
  HTTPAPI_SET_OPTION_FAILED,
  HTTPAPI_SEND_REQUEST_FAILED,
  HTTPAPI_RECEIVE_RESPONSE_FAILED,
  HTTPAPI_QUERY_HEADERS_FAILED,
  HTTPAPI_QUERY_DATA_AVAILABLE_FAILED,
  HTTPAPI_READ_DATA_FAILED,
  HTTPAPI_ALREADY_INIT,
  HTTPAPI_NOT_INIT,
  HTTPAPI_HTTP_HEADERS_FAILED,
  HTTPAPI_STRING_PROCESSING_ERROR,
  HTTPAPI_ALLOC_FAILED,
  HTTPAPI_INIT_FAILED,
  HTTPAPI_INSUFFICIENT_RESPONSE_BUFFER,
  HTTPAPI_SET_X509_FAILURE,
  HTTPAPI_SET_TIMEOUTS_FAILED
}

HTTPAPI_REQUEST_TYPE

Enumeration specifying the HTTP request verbs accepted by the HTTPAPI module.

enum HTTPAPI_REQUEST_TYPE {
  HTTPAPI_REQUEST_TYPE_INVALID,
  HTTPAPI_REQUEST_GET,
  HTTPAPI_REQUEST_POST,
  HTTPAPI_REQUEST_PUT,
  HTTPAPI_REQUEST_DELETE,
  HTTPAPI_REQUEST_PATCH,
  HTTPAPI_REQUEST_HEAD
}

Type definitions

HTTP_HANDLE

typedef struct HTTP_HANDLE_DATA_TAG* HTTP_HANDLE;