Network Services API  2.40.00.11
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
HTTP Client

The HTTP client provides APIs to connect to, and communicate with, HTTP Servers. More...

Data Structures

struct  HTTPClient_extSecParams
 

Macros

#define HTTPClient_DOMAIN_BUFLEN   (100)
 
#define HTTPClient_RES_HFIELD_BUFFER_SIZE   (300)
 
#define HTTPClient_MIN_USER_WORKSPACE_SIZE   (500)
 
#define HTTPClient_MAX_REDIRECTION_ATTEMPTS   (3)
 
#define HTTPClient_MAX_REQUEST_ATTEMPTS   (2)
 
#define HTTPClient_MAX_RESPONSE_HEADER_FILEDS   (25)
 
#define HTTPClient_PORT   (80)
 
#define HTTPClient_SECURE_PORT   (443)
 
#define HTTPClient_HFIELD_RES_AGE   (0)
 
#define HTTPClient_HFIELD_RES_ALLOW   (1)
 
#define HTTPClient_HFIELD_RES_CACHE_CONTROL   (2)
 
#define HTTPClient_HFIELD_RES_CONNECTION   (3)
 
#define HTTPClient_HFIELD_RES_CONTENT_ENCODING   (4)
 
#define HTTPClient_HFIELD_RES_CONTENT_LANGUAGE   (5)
 
#define HTTPClient_HFIELD_RES_CONTENT_LENGTH   (6)
 
#define HTTPClient_HFIELD_RES_CONTENT_LOCATION   (7)
 
#define HTTPClient_HFIELD_RES_CONTENT_RANGE   (8)
 
#define HTTPClient_HFIELD_RES_CONTENT_TYPE   (9)
 
#define HTTPClient_HFIELD_RES_DATE   (10)
 
#define HTTPClient_HFIELD_RES_ETAG   (11)
 
#define HTTPClient_HFIELD_RES_EXPIRES   (12)
 
#define HTTPClient_HFIELD_RES_LAST_MODIFIED   (13)
 
#define HTTPClient_HFIELD_RES_LOCATION   (14)
 
#define HTTPClient_HFIELD_RES_PROXY_AUTHENTICATE   (15)
 
#define HTTPClient_HFIELD_RES_RETRY_AFTER   (16)
 
#define HTTPClient_HFIELD_RES_SERVER   (17)
 
#define HTTPClient_HFIELD_RES_SET_COOKIE   (18)
 
#define HTTPClient_HFIELD_RES_TRAILER   (19)
 
#define HTTPClient_HFIELD_RES_TRANSFER_ENCODING   (20)
 
#define HTTPClient_HFIELD_RES_UPGRADE   (21)
 
#define HTTPClient_HFIELD_RES_VARY   (22)
 
#define HTTPClient_HFIELD_RES_VIA   (23)
 
#define HTTPClient_HFIELD_RES_WWW_AUTHENTICATE   (24)
 
#define HTTPClient_HFIELD_RES_WARNING   (25)
 
#define HTTPClient_REQUEST_HEADER_MASK   (0x80000000)
 
#define HTTPClient_HFIELD_REQ_ACCEPT   (26 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_ACCEPT_CHARSET   (27 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_ACCEPT_ENCODING   (28 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_ACCEPT_LANGUAGE   (29 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_ALLOW   (HTTPClient_HFIELD_RES_ALLOW | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_AUTHORIZATION   (30 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_CACHE_CONTROL   (HTTPClient_HFIELD_RES_CACHE_CONTROL | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_CONNECTION   (HTTPClient_HFIELD_RES_CONNECTION | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_CONTENT_ENCODING   (HTTPClient_HFIELD_RES_CONTENT_ENCODING | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_CONTENT_LANGUAGE   (HTTPClient_HFIELD_RES_CONTENT_LANGUAGE | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_CONTENT_LOCATION   (HTTPClient_HFIELD_RES_CONTENT_LOCATION | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_CONTENT_TYPE   (HTTPClient_HFIELD_RES_CONTENT_TYPE | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_COOKIE   (31 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_DATE   (HTTPClient_HFIELD_RES_DATE | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_EXPECT   (32 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_FORWARDED   (33 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_FROM   (34 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_HOST   (35 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_IF_MATCH   (36 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_IF_MODIFIED_SINCE   (37 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_IF_NONE_MATCH   (38 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_IF_RANGE   (39 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_IF_UNMODIFIED_SINCE   (40 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_ORIGIN   (41 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_PROXY_AUTHORIZATION   (42 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_RANGE   (43 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_TE   (44 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_TRANSFER_ENCODING   (HTTPClient_HFIELD_RES_TRANSFER_ENCODING | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_UPGRADE   (HTTPClient_HFIELD_RES_UPGRADE | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_USER_AGENT   (45 | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_VIA   (HTTPClient_HFIELD_RES_VIA | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_HFIELD_REQ_WARNING   (HTTPClient_HFIELD_RES_WARNING | HTTPClient_REQUEST_HEADER_MASK)
 
#define HTTPClient_MAX_NUMBER_OF_HEADER_FIELDS   (46)
 
#define HTTPClient_REDIRECT_FEATURE   (48)
 
#define HTTPClient_RESPONSE_FILTER_CLEAR   (49)
 
#define HTTPClient_REDIRECT_TLS_DOWNGRADE   (50)
 
#define HTTPClient_AUTHENTICATE_SERVER_CALLBACK   (51)
 Attaches callback which will handle the server authentication response (401) More...
 
#define HTTPClient_ESENDBUFSMALL   (-3001)
 Internal send buffer is not big enough. More...
 
#define HTTPClient_EGETOPTBUFSMALL   (-3002)
 Buffer inserted into HTTPClient_getOpt() is not big enough. More...
 
#define HTTPClient_ERESPONSEINVALID   (-3003)
 Response recieved from the server is not a valid HTTP/1.1 or HTTP/1.0 response. More...
 
#define HTTPClient_EINPROGRESS   (-3004)
 Operation could not be completed. Try again. More...
 
#define HTTPClient_EDOMAINBUFSMALL   (-3005)
 Input domain name length is too long to be read into buffer. More...
 
#define HTTPClient_ECBALLOCATIONFAILED   (-3006)
 Allocation failed during the CB creation. More...
 
#define HTTPClient_EBODYBUFSMALL   (-3008)
 Body size is too small. More...
 
#define HTTPClient_ENULLPOINTER   (-3009)
 Invalid de-referencing a NULL pointer. More...
 
#define HTTPClient_EREQUESTHEADERALLOCFAILED   (-3010)
 Request header allocation failed. More...
 
#define HTTPClient_EREQHEADERNOTFOUND   (-3011)
 Request header wasn't found in the req header list. More...
 
#define HTTPClient_EHOSTNOTFOUND   (-3012)
 Host request header wasn't found. More...
 
#define HTTPClient_ECLIENTALREADYCONNECTED   (-3013)
 Client is already connected. More...
 
#define HTTPClient_ERESPONSEISNOTREDIRECTABLE   (-3014)
 Response is not redirectable. More...
 
#define HTTPClient_ESENDERROR   (-3015)
 Send couldn't be completed. More...
 
#define HTTPClient_EREDIRECTLOCATIONFAIL   (-3016)
 Location Header fields value couldn't be read completely. More...
 
#define HTTPClient_ETLSDOWNGRADEISFORBIDDEN   (-3017)
 TLS downgrade is forbidden. More...
 
#define HTTPClient_EWRONGAPIPARAMETER   (-3018)
 Wrong API parameter. More...
 
#define HTTPClient_EHOSTHEADERALREADYEXIST   (-3019)
 HOST already exist. More...
 
#define HTTPClient_ENOCONNECTION   (-3020)
 Client is disconnected. More...
 
#define HTTPClient_ENOTABSOLUTEURI   (-3021)
 URI is not absolute. More...
 
#define HTTPClient_ECANTCREATESECATTRIB   (-3022)
 Error during creation of security attribute. More...
 
#define HTTPClient_IGNORE_PROXY   (0x01)
 
#define HTTPClient_HOST_EXIST   (0x02)
 
#define HTTPClient_HFIELD_NOT_PERSISTENT   (0x01)
 
#define HTTPClient_HFIELD_PERSISTENT   (0x02)
 
#define HTTPClient_CHUNK_START   (0x01)
 
#define HTTPClient_CHUNK_END   (0x02)
 
#define HTTPClient_DROP_BODY   (0x04)
 

Typedefs

typedef struct HTTPClient_extSecParams HTTPClient_extSecParams
 
typedef int16_t(* HTTPClient_authenticationCallback) (const char *serverAuthBuff, uint32_t serverAuthLen, char *clientAuthBuff, uint32_t *clientAuthLen)
 HTTPClient callback for server authentication handling This function is responsible for generating the value for the authorization request header. More...
 
typedef void * HTTPClient_Handle
 

Enumerations

enum  HTTP_STATUS_CODE {
  HTTP_SC_CONTINUE = 100,
  HTTP_SC_SWITCHING_PROTOCOLS = 101,
  HTTP_SC_OK = 200,
  HTTP_SC_CREATED = 201,
  HTTP_SC_ACCEPTED = 202,
  HTTP_SC_NON_AUTHORITATIVE_INFORMATION = 203,
  HTTP_SC_NO_CONTENT = 204,
  HTTP_SC_RESET_CONTENT = 205,
  HTTP_SC_PARTIAL_CONTENT = 206,
  HTTP_SC_MULTI_STATUS = 207,
  HTTP_SC_MULTIPLE_CHOICES = 300,
  HTTP_SC_MOVED_PERMANENTLY = 301,
  HTTP_SC_FOUND = 302,
  HTTP_SC_SEE_OTHER = 303,
  HTTP_SC_NOT_MODIFIED = 304,
  HTTP_SC_TEMPORARY_REDIRECT = 307,
  HTTP_SC_BAD_REQUEST = 400,
  HTTP_SC_UNAUTHORIZED = 401,
  HTTP_SC_PAYMENT_REQUIRED = 402,
  HTTP_SC_FORBIDDEN = 403,
  HTTP_SC_NOT_FOUND = 404,
  HTTP_SC_METHOD_NOT_ALLOWED = 405,
  HTTP_SC_NOT_ACCEPTABLE = 406,
  HTTP_SC_PROXY_AUTHENTICATION_REQUIRED = 407,
  HTTP_SC_REQUEST_TIMEOUT = 408,
  HTTP_SC_CONFLICT = 409,
  HTTP_SC_GONE = 410,
  HTTP_SC_LENGTH_REQUIRED = 411,
  HTTP_SC_PRECONDITION_FAILED = 412,
  HTTP_SC_REQUEST_ENTITY_TOO_LARGE = 413,
  HTTP_SC_REQUEST_URI_TOO_LONG = 414,
  HTTP_SC_UNSUPPORTED_MEDIA_TYPE = 415,
  HTTP_SC_REQUESTED_RANGE_NOT_SATISFAIABLE = 416,
  HTTP_SC_EXPECTATION_FAILED = 417,
  HTTP_SC_UNPROCESSABLE_ENTITY = 422,
  HTTP_SC_UPGRADE_REQUIRED = 426,
  HTTP_SC_TOO_MANY_REQUESTS = 429,
  HTTP_SC_INTERNAL_SERVER_ERROR = 500,
  HTTP_SC_NOT_IMPLEMENTED = 501,
  HTTP_SC_BAD_GATEWAY = 502,
  HTTP_SC_SERVICE_UNAVAILABLE = 503,
  HTTP_SC_GATEWAY_TIMEOUT = 504,
  HTTP_SC_HTTP_VERSION_NOT_SUPPORTED = 505,
  HTTP_SC_STATUS_CODE_END = 600
}
 

Functions

HTTPClient_Handle HTTPClient_create (int16_t *status, void *params)
 Allocate and initialize a new HTTPClient instance object and return its handle. More...
 
int16_t HTTPClient_destroy (HTTPClient_Handle client)
 Destroy the HTTP client instance and free the previously allocated instance object. More...
 
int16_t HTTPClient_connect (HTTPClient_Handle client, const char *hostName, HTTPClient_extSecParams *exSecParams, uint32_t flags)
 Open a connection to an HTTP server. A user can connect to a HTTP server using TLS,proxy or both. More...
 
int16_t HTTPClient_disconnect (HTTPClient_Handle client)
 Disconnect from the HTTP server. More...
 
int16_t HTTPClient_sendRequest (HTTPClient_Handle client, const char *method, const char *requestURI, const char *body, uint32_t bodyLen, uint32_t flags)
 Make an HTTP request to the HTTP server. More...
 
int16_t HTTPClient_readResponseBody (HTTPClient_Handle client, char *body, uint32_t bodyLen, bool *moreDataFlag)
 Read the response body data from the HTTP server The function handles both oneshot and chunked body responses. More...
 
int16_t HTTPClient_setHeader (HTTPClient_Handle client, uint32_t option, void *value, uint32_t len, uint32_t flags)
 Setting HTTP Client Header-field configurations. More...
 
int16_t HTTPClient_setHeaderByName (HTTPClient_Handle client, uint32_t option, const char *name, void *value, uint32_t len, uint32_t flags)
 Setting HTTP Client Header-field configurations by header name. Both standard (as defined by the HTTP RFC spec) and non-standard header names are supported. This API currently only supports request headers. More...
 
int16_t HTTPClient_getHeader (HTTPClient_Handle client, uint32_t option, void *value, uint32_t *len, uint32_t flags)
 Getting HTTP Client Header-field configurations. More...
 
int16_t HTTPClient_setOpt (HTTPClient_Handle client, uint32_t option, void *value, uint32_t len, uint32_t flags)
 Setting HTTP Client configurations. More...
 
int16_t HTTPClient_getOpt (HTTPClient_Handle client, uint32_t option, void *value, uint32_t *len, uint32_t flags)
 Getting HTTP Client configurations. More...
 
void HTTPClient_setProxy (const SlNetSock_Addr_t *addr)
 Set the proxy address. More...
 

Variables

const char * HTTP_METHOD_GET
 
const char * HTTP_METHOD_POST
 
const char * HTTP_METHOD_HEAD
 
const char * HTTP_METHOD_OPTIONS
 
const char * HTTP_METHOD_PUT
 
const char * HTTP_METHOD_DELETE
 
const char * HTTP_METHOD_CONNECT
 

Detailed Description

The HTTP client provides APIs to connect to, and communicate with, HTTP Servers.

Library Usage

To use the HTTPClient APIs, the application should include its header file as follows:

And, add the following HTTP library to the link line:

.../source/ti/net/http/{toolchain}/{isa}/httpclient_{profile}.a

Macro Definition Documentation

§ HTTPClient_DOMAIN_BUFLEN

#define HTTPClient_DOMAIN_BUFLEN   (100)

§ HTTPClient_RES_HFIELD_BUFFER_SIZE

#define HTTPClient_RES_HFIELD_BUFFER_SIZE   (300)

Size of the buffer which is used to store response values

§ HTTPClient_MIN_USER_WORKSPACE_SIZE

#define HTTPClient_MIN_USER_WORKSPACE_SIZE   (500)

Minimum workspace size user should alloc in order to create client handle

§ HTTPClient_MAX_REDIRECTION_ATTEMPTS

#define HTTPClient_MAX_REDIRECTION_ATTEMPTS   (3)

§ HTTPClient_MAX_REQUEST_ATTEMPTS

#define HTTPClient_MAX_REQUEST_ATTEMPTS   (2)

§ HTTPClient_MAX_RESPONSE_HEADER_FILEDS

#define HTTPClient_MAX_RESPONSE_HEADER_FILEDS   (25)

§ HTTPClient_PORT

#define HTTPClient_PORT   (80)

§ HTTPClient_SECURE_PORT

#define HTTPClient_SECURE_PORT   (443)

§ HTTPClient_HFIELD_RES_AGE

#define HTTPClient_HFIELD_RES_AGE   (0)

§ HTTPClient_HFIELD_RES_ALLOW

#define HTTPClient_HFIELD_RES_ALLOW   (1)

§ HTTPClient_HFIELD_RES_CACHE_CONTROL

#define HTTPClient_HFIELD_RES_CACHE_CONTROL   (2)

§ HTTPClient_HFIELD_RES_CONNECTION

#define HTTPClient_HFIELD_RES_CONNECTION   (3)

§ HTTPClient_HFIELD_RES_CONTENT_ENCODING

#define HTTPClient_HFIELD_RES_CONTENT_ENCODING   (4)

§ HTTPClient_HFIELD_RES_CONTENT_LANGUAGE

#define HTTPClient_HFIELD_RES_CONTENT_LANGUAGE   (5)

§ HTTPClient_HFIELD_RES_CONTENT_LENGTH

#define HTTPClient_HFIELD_RES_CONTENT_LENGTH   (6)

§ HTTPClient_HFIELD_RES_CONTENT_LOCATION

#define HTTPClient_HFIELD_RES_CONTENT_LOCATION   (7)

§ HTTPClient_HFIELD_RES_CONTENT_RANGE

#define HTTPClient_HFIELD_RES_CONTENT_RANGE   (8)

§ HTTPClient_HFIELD_RES_CONTENT_TYPE

#define HTTPClient_HFIELD_RES_CONTENT_TYPE   (9)

§ HTTPClient_HFIELD_RES_DATE

#define HTTPClient_HFIELD_RES_DATE   (10)

§ HTTPClient_HFIELD_RES_ETAG

#define HTTPClient_HFIELD_RES_ETAG   (11)

§ HTTPClient_HFIELD_RES_EXPIRES

#define HTTPClient_HFIELD_RES_EXPIRES   (12)

§ HTTPClient_HFIELD_RES_LAST_MODIFIED

#define HTTPClient_HFIELD_RES_LAST_MODIFIED   (13)

§ HTTPClient_HFIELD_RES_LOCATION

#define HTTPClient_HFIELD_RES_LOCATION   (14)

§ HTTPClient_HFIELD_RES_PROXY_AUTHENTICATE

#define HTTPClient_HFIELD_RES_PROXY_AUTHENTICATE   (15)

§ HTTPClient_HFIELD_RES_RETRY_AFTER

#define HTTPClient_HFIELD_RES_RETRY_AFTER   (16)

§ HTTPClient_HFIELD_RES_SERVER

#define HTTPClient_HFIELD_RES_SERVER   (17)

§ HTTPClient_HFIELD_RES_SET_COOKIE

#define HTTPClient_HFIELD_RES_SET_COOKIE   (18)

§ HTTPClient_HFIELD_RES_TRAILER

#define HTTPClient_HFIELD_RES_TRAILER   (19)

§ HTTPClient_HFIELD_RES_TRANSFER_ENCODING

#define HTTPClient_HFIELD_RES_TRANSFER_ENCODING   (20)

§ HTTPClient_HFIELD_RES_UPGRADE

#define HTTPClient_HFIELD_RES_UPGRADE   (21)

§ HTTPClient_HFIELD_RES_VARY

#define HTTPClient_HFIELD_RES_VARY   (22)

§ HTTPClient_HFIELD_RES_VIA

#define HTTPClient_HFIELD_RES_VIA   (23)

§ HTTPClient_HFIELD_RES_WWW_AUTHENTICATE

#define HTTPClient_HFIELD_RES_WWW_AUTHENTICATE   (24)

§ HTTPClient_HFIELD_RES_WARNING

#define HTTPClient_HFIELD_RES_WARNING   (25)

§ HTTPClient_REQUEST_HEADER_MASK

#define HTTPClient_REQUEST_HEADER_MASK   (0x80000000)

§ HTTPClient_HFIELD_REQ_ACCEPT

#define HTTPClient_HFIELD_REQ_ACCEPT   (26 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_ACCEPT_CHARSET

#define HTTPClient_HFIELD_REQ_ACCEPT_CHARSET   (27 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_ACCEPT_ENCODING

#define HTTPClient_HFIELD_REQ_ACCEPT_ENCODING   (28 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_ACCEPT_LANGUAGE

#define HTTPClient_HFIELD_REQ_ACCEPT_LANGUAGE   (29 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_ALLOW

#define HTTPClient_HFIELD_REQ_ALLOW   (HTTPClient_HFIELD_RES_ALLOW | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_AUTHORIZATION

#define HTTPClient_HFIELD_REQ_AUTHORIZATION   (30 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_CACHE_CONTROL

#define HTTPClient_HFIELD_REQ_CACHE_CONTROL   (HTTPClient_HFIELD_RES_CACHE_CONTROL | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_CONNECTION

#define HTTPClient_HFIELD_REQ_CONNECTION   (HTTPClient_HFIELD_RES_CONNECTION | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_CONTENT_ENCODING

#define HTTPClient_HFIELD_REQ_CONTENT_ENCODING   (HTTPClient_HFIELD_RES_CONTENT_ENCODING | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_CONTENT_LANGUAGE

#define HTTPClient_HFIELD_REQ_CONTENT_LANGUAGE   (HTTPClient_HFIELD_RES_CONTENT_LANGUAGE | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_CONTENT_LOCATION

#define HTTPClient_HFIELD_REQ_CONTENT_LOCATION   (HTTPClient_HFIELD_RES_CONTENT_LOCATION | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_CONTENT_TYPE

#define HTTPClient_HFIELD_REQ_CONTENT_TYPE   (HTTPClient_HFIELD_RES_CONTENT_TYPE | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_COOKIE

#define HTTPClient_HFIELD_REQ_COOKIE   (31 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_DATE

#define HTTPClient_HFIELD_REQ_DATE   (HTTPClient_HFIELD_RES_DATE | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_EXPECT

#define HTTPClient_HFIELD_REQ_EXPECT   (32 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_FORWARDED

#define HTTPClient_HFIELD_REQ_FORWARDED   (33 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_FROM

#define HTTPClient_HFIELD_REQ_FROM   (34 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_HOST

#define HTTPClient_HFIELD_REQ_HOST   (35 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_IF_MATCH

#define HTTPClient_HFIELD_REQ_IF_MATCH   (36 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_IF_MODIFIED_SINCE

#define HTTPClient_HFIELD_REQ_IF_MODIFIED_SINCE   (37 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_IF_NONE_MATCH

#define HTTPClient_HFIELD_REQ_IF_NONE_MATCH   (38 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_IF_RANGE

#define HTTPClient_HFIELD_REQ_IF_RANGE   (39 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_IF_UNMODIFIED_SINCE

#define HTTPClient_HFIELD_REQ_IF_UNMODIFIED_SINCE   (40 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_ORIGIN

#define HTTPClient_HFIELD_REQ_ORIGIN   (41 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_PROXY_AUTHORIZATION

#define HTTPClient_HFIELD_REQ_PROXY_AUTHORIZATION   (42 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_RANGE

#define HTTPClient_HFIELD_REQ_RANGE   (43 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_TE

#define HTTPClient_HFIELD_REQ_TE   (44 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_TRANSFER_ENCODING

#define HTTPClient_HFIELD_REQ_TRANSFER_ENCODING   (HTTPClient_HFIELD_RES_TRANSFER_ENCODING | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_UPGRADE

#define HTTPClient_HFIELD_REQ_UPGRADE   (HTTPClient_HFIELD_RES_UPGRADE | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_USER_AGENT

#define HTTPClient_HFIELD_REQ_USER_AGENT   (45 | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_VIA

#define HTTPClient_HFIELD_REQ_VIA   (HTTPClient_HFIELD_RES_VIA | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_HFIELD_REQ_WARNING

#define HTTPClient_HFIELD_REQ_WARNING   (HTTPClient_HFIELD_RES_WARNING | HTTPClient_REQUEST_HEADER_MASK)

§ HTTPClient_MAX_NUMBER_OF_HEADER_FIELDS

#define HTTPClient_MAX_NUMBER_OF_HEADER_FIELDS   (46)

§ HTTPClient_REDIRECT_FEATURE

#define HTTPClient_REDIRECT_FEATURE   (48)

Enable / Disable redirect feature

§ HTTPClient_RESPONSE_FILTER_CLEAR

#define HTTPClient_RESPONSE_FILTER_CLEAR   (49)

Clear response filter to default(all enabled)

§ HTTPClient_REDIRECT_TLS_DOWNGRADE

#define HTTPClient_REDIRECT_TLS_DOWNGRADE   (50)

Enable / Disable the option for tls downgrade

§ HTTPClient_AUTHENTICATE_SERVER_CALLBACK

#define HTTPClient_AUTHENTICATE_SERVER_CALLBACK   (51)

Attaches callback which will handle the server authentication response (401)

§ HTTPClient_ESENDBUFSMALL

#define HTTPClient_ESENDBUFSMALL   (-3001)

Internal send buffer is not big enough.

Define HTTPClient_BUF_LEN in httpclient_internal.h and rebuild the library.

§ HTTPClient_EGETOPTBUFSMALL

#define HTTPClient_EGETOPTBUFSMALL   (-3002)

Buffer inserted into HTTPClient_getOpt() is not big enough.

§ HTTPClient_ERESPONSEINVALID

#define HTTPClient_ERESPONSEINVALID   (-3003)

Response recieved from the server is not a valid HTTP/1.1 or HTTP/1.0 response.

§ HTTPClient_EINPROGRESS

#define HTTPClient_EINPROGRESS   (-3004)

Operation could not be completed. Try again.

§ HTTPClient_EDOMAINBUFSMALL

#define HTTPClient_EDOMAINBUFSMALL   (-3005)

Input domain name length is too long to be read into buffer.

Modify the HTTPClient_DOMAIN_BUFLEN and rebuild the library.

See also
HTTPClient_DOMAIN_BUFLEN

§ HTTPClient_ECBALLOCATIONFAILED

#define HTTPClient_ECBALLOCATIONFAILED   (-3006)

Allocation failed during the CB creation.

Check whether there is free memory for CB allocation.

§ HTTPClient_EBODYBUFSMALL

#define HTTPClient_EBODYBUFSMALL   (-3008)

Body size is too small.

Body which was entered into the request was too small, This error won't occur if the body size will be at least HTTPClient_BUF_LEN.

§ HTTPClient_ENULLPOINTER

#define HTTPClient_ENULLPOINTER   (-3009)

Invalid de-referencing a NULL pointer.

Check that a NULL pointer wasn't dereferenced in the function.

§ HTTPClient_EREQUESTHEADERALLOCFAILED

#define HTTPClient_EREQUESTHEADERALLOCFAILED   (-3010)

Request header allocation failed.

§ HTTPClient_EREQHEADERNOTFOUND

#define HTTPClient_EREQHEADERNOTFOUND   (-3011)

Request header wasn't found in the req header list.

§ HTTPClient_EHOSTNOTFOUND

#define HTTPClient_EHOSTNOTFOUND   (-3012)

Host request header wasn't found.

Host header-field is mandatory.

§ HTTPClient_ECLIENTALREADYCONNECTED

#define HTTPClient_ECLIENTALREADYCONNECTED   (-3013)

Client is already connected.

§ HTTPClient_ERESPONSEISNOTREDIRECTABLE

#define HTTPClient_ERESPONSEISNOTREDIRECTABLE   (-3014)

Response is not redirectable.

§ HTTPClient_ESENDERROR

#define HTTPClient_ESENDERROR   (-3015)

Send couldn't be completed.

§ HTTPClient_EREDIRECTLOCATIONFAIL

#define HTTPClient_EREDIRECTLOCATIONFAIL   (-3016)

Location Header fields value couldn't be read completely.

Since the "Location" header-field is essential for the redirect mechanism it is imposible to complete the redirect without it. This error indicates that the buffer for the Location header field value was too small. Enlarge HTTPClient_BUF_LEN in order to fix this error, or disable the redirect mechanism.

§ HTTPClient_ETLSDOWNGRADEISFORBIDDEN

#define HTTPClient_ETLSDOWNGRADEISFORBIDDEN   (-3017)

TLS downgrade is forbidden.

This error indicates that after redirect occured, the server asked the client to redirect from secured server into non-secured server. This option is forbidden by default, to enable use HTTPClient_setOpt()

§ HTTPClient_EWRONGAPIPARAMETER

#define HTTPClient_EWRONGAPIPARAMETER   (-3018)

Wrong API parameter.

Wrong parameter entered into the API.

§ HTTPClient_EHOSTHEADERALREADYEXIST

#define HTTPClient_EHOSTHEADERALREADYEXIST   (-3019)

HOST already exist.

Host header is already exist, having multiple Host headers is invalid. Remove the existing host Header.

§ HTTPClient_ENOCONNECTION

#define HTTPClient_ENOCONNECTION   (-3020)

Client is disconnected.

SlNetSock_recv return 0 which means the client is disconnected.

§ HTTPClient_ENOTABSOLUTEURI

#define HTTPClient_ENOTABSOLUTEURI   (-3021)

URI is not absolute.

When Host header is not found, reconnection can be established only with absolute URI.

§ HTTPClient_ECANTCREATESECATTRIB

#define HTTPClient_ECANTCREATESECATTRIB   (-3022)

Error during creation of security attribute.

Error occured during the creationg of security attribue

§ HTTPClient_IGNORE_PROXY

#define HTTPClient_IGNORE_PROXY   (0x01)

If proxy is set, this flag makes the connection without the proxy

§ HTTPClient_HOST_EXIST

#define HTTPClient_HOST_EXIST   (0x02)

§ HTTPClient_HFIELD_NOT_PERSISTENT

#define HTTPClient_HFIELD_NOT_PERSISTENT   (0x01)

Header Field added is not persistent

§ HTTPClient_HFIELD_PERSISTENT

#define HTTPClient_HFIELD_PERSISTENT   (0x02)

Header Field added is persistent

§ HTTPClient_CHUNK_START

#define HTTPClient_CHUNK_START   (0x01)

Sets the client's request state into chunked body

§ HTTPClient_CHUNK_END

#define HTTPClient_CHUNK_END   (0x02)

Sets the client's request state out of chunked body and sends last chunk

§ HTTPClient_DROP_BODY

#define HTTPClient_DROP_BODY   (0x04)

Flushes the response body

Typedef Documentation

§ HTTPClient_extSecParams

§ HTTPClient_authenticationCallback

typedef int16_t(* HTTPClient_authenticationCallback) (const char *serverAuthBuff, uint32_t serverAuthLen, char *clientAuthBuff, uint32_t *clientAuthLen)

HTTPClient callback for server authentication handling This function is responsible for generating the value for the authorization request header.

Parameters
[in]serverAuthBuffBuffer containing authentication information (Www-Authenticate response header) received from server.
[in]serverAuthLenServer authentication buffer length.
[out]clientAuthBuffBuffer containing Authorization request header.
[in,out]clientAuthLenInput is the maximum size of the client Authorization request header buffer (HTTPClient_BUF_LEN), Output is the actual size of the client Authorization request header buffer.
Returns
0 on success or error code on failure.

§ HTTPClient_Handle

typedef void* HTTPClient_Handle

Enumeration Type Documentation

§ HTTP_STATUS_CODE

Enumerator
HTTP_SC_CONTINUE 

Informational

HTTP_SC_SWITCHING_PROTOCOLS 

Informational

HTTP_SC_OK 

Success

HTTP_SC_CREATED 

Success

HTTP_SC_ACCEPTED 

Success

HTTP_SC_NON_AUTHORITATIVE_INFORMATION 

Success

HTTP_SC_NO_CONTENT 

Success

HTTP_SC_RESET_CONTENT 

Success

HTTP_SC_PARTIAL_CONTENT 

Success

HTTP_SC_MULTI_STATUS 

Success

HTTP_SC_MULTIPLE_CHOICES 

Redirection

HTTP_SC_MOVED_PERMANENTLY 

Redirection

HTTP_SC_FOUND 

Redirection

HTTP_SC_SEE_OTHER 

Redirection

HTTP_SC_NOT_MODIFIED 

Redirection

HTTP_SC_TEMPORARY_REDIRECT 

Redirection

HTTP_SC_BAD_REQUEST 

Client Error

HTTP_SC_UNAUTHORIZED 

Client Error

HTTP_SC_PAYMENT_REQUIRED 

Client Error

HTTP_SC_FORBIDDEN 

Client Error

HTTP_SC_NOT_FOUND 

Client Error

HTTP_SC_METHOD_NOT_ALLOWED 

Client Error

HTTP_SC_NOT_ACCEPTABLE 

Client Error

HTTP_SC_PROXY_AUTHENTICATION_REQUIRED 

Client Error

HTTP_SC_REQUEST_TIMEOUT 

Client Error

HTTP_SC_CONFLICT 

Client Error

HTTP_SC_GONE 

Client Error

HTTP_SC_LENGTH_REQUIRED 

Client Error

HTTP_SC_PRECONDITION_FAILED 

Client Error

HTTP_SC_REQUEST_ENTITY_TOO_LARGE 

Client Error

HTTP_SC_REQUEST_URI_TOO_LONG 

Client Error

HTTP_SC_UNSUPPORTED_MEDIA_TYPE 

Client Error

HTTP_SC_REQUESTED_RANGE_NOT_SATISFAIABLE 

Client Error

HTTP_SC_EXPECTATION_FAILED 

Client Error

HTTP_SC_UNPROCESSABLE_ENTITY 

Client Error

HTTP_SC_UPGRADE_REQUIRED 

Client Error

HTTP_SC_TOO_MANY_REQUESTS 

Client Error

HTTP_SC_INTERNAL_SERVER_ERROR 

Server Error

HTTP_SC_NOT_IMPLEMENTED 

Server Error

HTTP_SC_BAD_GATEWAY 

Server Error

HTTP_SC_SERVICE_UNAVAILABLE 

Server Error

HTTP_SC_GATEWAY_TIMEOUT 

Server Error

HTTP_SC_HTTP_VERSION_NOT_SUPPORTED 

Server Error

HTTP_SC_STATUS_CODE_END 

Function Documentation

§ HTTPClient_create()

HTTPClient_Handle HTTPClient_create ( int16_t *  status,
void *  params 
)

Allocate and initialize a new HTTPClient instance object and return its handle.

Parameters
[out]statuspointer to return status
[in]paramsSpecial parameters for creating the instance (currently there are no special parameters)
Returns
handle on success or NULL failure.

§ HTTPClient_destroy()

int16_t HTTPClient_destroy ( HTTPClient_Handle  client)

Destroy the HTTP client instance and free the previously allocated instance object.

Parameters
[in]clientPointer to the HTTP client instance
Returns
0 on success or error code on failure.

§ HTTPClient_connect()

int16_t HTTPClient_connect ( HTTPClient_Handle  client,
const char *  hostName,
HTTPClient_extSecParams exSecParams,
uint32_t  flags 
)

Open a connection to an HTTP server. A user can connect to a HTTP server using TLS,proxy or both.

Parameters
[in]clientInstance of an HTTP client
[in]hostNameIP address or URL of the HTTP server.
[in]exSecParamsexternal parameters for configuring security.
[in]flagsSpecial flags for connection:
Returns
0 on success or error code on failure.

§ HTTPClient_disconnect()

int16_t HTTPClient_disconnect ( HTTPClient_Handle  client)

Disconnect from the HTTP server.

Parameters
[in]clientInstance of the HTTP client
Returns
0 on success or error code on failure.

§ HTTPClient_sendRequest()

int16_t HTTPClient_sendRequest ( HTTPClient_Handle  client,
const char *  method,
const char *  requestURI,
const char *  body,
uint32_t  bodyLen,
uint32_t  flags 
)

Make an HTTP request to the HTTP server.

Sends an HTTP request-line, header fields and body to the requested URI. After sending the request, the request function waits for the response Status and Header-Fields. According to the response status, the request function determines whether to return to user or to call a redirect/callback pre-defined function.

Parameters
[in]clientInstance of an HTTP client.
[in]methodHTTP method.
[in]requestURIThe path on the server to open.
[in]bodyThe body the user wishes to send in in the request, The body can be chunked or one body buffer.
[in]bodyLenLength of the body sent in the request.
[in]flagsSpecial flags when the user wishes not to use the default settings.
Note
- If user wishes to use TLS connection then before calling HTTPClient_sendRequest(), HTTPClient_connect() should be called.
  • If disconnection happened prior to HTTPClient_sendRequest(), HTTPClient_sendRequest() will reconnect internally.
  • When sending a body in a request, the "Content-length: " and "Transfer-Encoding: Chunked" headers will be added automatically.
Returns
Response status code on success or error code on failure.

§ HTTPClient_readResponseBody()

int16_t HTTPClient_readResponseBody ( HTTPClient_Handle  client,
char *  body,
uint32_t  bodyLen,
bool *  moreDataFlag 
)

Read the response body data from the HTTP server The function handles both oneshot and chunked body responses.

Make a call to this function only after the call to HTTPClient_sendRequest().

Parameters
[in]clientInstance of an HTTP client
[out]bodyResponse body buffer
[in]bodyLenLength of response body buffer
[out]moreDataFlagSet if more data is available
Note
Make a call to this function only after the call to HTTPClient_sendRequest(). This function need to be called until moreDataFlag will be false(All data was read).
Returns
The number of characters read on success or error code on failure

§ HTTPClient_setHeader()

int16_t HTTPClient_setHeader ( HTTPClient_Handle  client,
uint32_t  option,
void *  value,
uint32_t  len,
uint32_t  flags 
)

Setting HTTP Client Header-field configurations.

Parameters
[in]clientInstance of an HTTP client
[in]optionOptions for setting could be one of the following: -Header-Fields ID - Request - headers - sets the headers-fields which will be used in requests. Response - headers - sets the headers-fields wanted to be filtered in a response. (if no request headers are set, all the headers will be available with size constraints)
[in]valueValue for setting could be any related value for the corresponding option. Value can be set to NULL when request header wanted to be removed.
[in]lenLength of the value.
[in]flagsFlags for settings need be one of the following:
Returns
0 on success or error code on failure.

§ HTTPClient_setHeaderByName()

int16_t HTTPClient_setHeaderByName ( HTTPClient_Handle  client,
uint32_t  option,
const char *  name,
void *  value,
uint32_t  len,
uint32_t  flags 
)

Setting HTTP Client Header-field configurations by header name. Both standard (as defined by the HTTP RFC spec) and non-standard header names are supported. This API currently only supports request headers.

When a given standard HTTP header is set, it is important to consistently set it using one of HTTPClient_setHeaderByName() or HTTPClient_setHeader(). The ordering of the values may not be preserved if both APIs are used to set the same header.

Parameters
[in]clientInstance of an HTTP client
[in]optionOptions for setting could be one of the following: HTTPClient_REQUEST_HEADER_MASK - sets a header-field which will be used in requests.
[in]nameName of header. Must be NULL-terminated.
[in]valueValue for setting could be any related value for the corresponding header.
[in]lenLength of the value.
[in]flagsFlags for settings need be one of the following:
Returns
0 on success or error code on failure.

§ HTTPClient_getHeader()

int16_t HTTPClient_getHeader ( HTTPClient_Handle  client,
uint32_t  option,
void *  value,
uint32_t *  len,
uint32_t  flags 
)

Getting HTTP Client Header-field configurations.

Parameters
[in]clientInstance of an HTTP client
[in]optionOptions for getting could be one of the following: -Header-Fields ID Response - headers - getting response headers-field value (only if value was received in a filtered response).
[out]valueValue for getting, could be any related value for the corresponding option.
[in,out]lenInputs Length of the value and output the actual length.
[in]flagsFlags for getting special configurations.
Returns
0 on success or error code on failure.

§ HTTPClient_setOpt()

int16_t HTTPClient_setOpt ( HTTPClient_Handle  client,
uint32_t  option,
void *  value,
uint32_t  len,
uint32_t  flags 
)

Setting HTTP Client configurations.

Parameters
[in]clientInstance of an HTTP client
[in]optionOptions for setting could be one of the following: -Client instance parameters:
[in]valueValue for setting could be any related value for the corresponding option.
[in]lenLength of the value.
[in]flagsFlags for settings special configurations.
Returns
0 on success or error code on failure.

§ HTTPClient_getOpt()

int16_t HTTPClient_getOpt ( HTTPClient_Handle  client,
uint32_t  option,
void *  value,
uint32_t *  len,
uint32_t  flags 
)

Getting HTTP Client configurations.

Parameters
[in]clientInstance of an HTTP client
[in]optionOptions for getting client settings.
[out]valueValue for getting, could be any related value for the corresponding option.
[in,out]lenInputs Length of the value and output the actual length.
[in]flagsFlags for getting special configurations
Note
Currently there are no client configurations to get.
Returns
0 on success or error code on failure.

§ HTTPClient_setProxy()

void HTTPClient_setProxy ( const SlNetSock_Addr_t addr)

Set the proxy address.

Parameters
[in]addrIP address of the proxy server

Variable Documentation

§ HTTP_METHOD_GET

const char* HTTP_METHOD_GET

§ HTTP_METHOD_POST

const char* HTTP_METHOD_POST

§ HTTP_METHOD_HEAD

const char* HTTP_METHOD_HEAD

§ HTTP_METHOD_OPTIONS

const char* HTTP_METHOD_OPTIONS

§ HTTP_METHOD_PUT

const char* HTTP_METHOD_PUT

§ HTTP_METHOD_DELETE

const char* HTTP_METHOD_DELETE

§ HTTP_METHOD_CONNECT

const char* HTTP_METHOD_CONNECT
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale