Network Services API
2.75.00.17
|
The HTTP client provides APIs to connect to, and communicate with, HTTP Servers. More...
Data Structures | |
struct | HTTPClient_extSecParams |
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 |
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_connect2 (HTTPClient_Handle client, const char *hostName, SlNetSockSecAttrib_t *secAttribs, uint32_t flags, int16_t *secureRetVal) |
Open a connection to an HTTP server. A user can connect to a HTTP server using TLS, proxy or both. HTTPClient_connect2 allows the user more control over security by accepting a secure attribute object and returning the value of the attempted secure connection. 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 supports request and response 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_getHeaderByName (HTTPClient_Handle client, uint32_t option, const char *name, void *value, uint32_t *len, uint32_t flags) |
Getting HTTP Client Header-field configurations. This API doesn't support removing existing custom header name, to do so please close the HTTPClient and reallocate it. This API for now, supports only custom 'response' headers. 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) |
Uses the http CONNECT method to create a tunnel through a remote proxy server to the host designated in HTTPClient_connect. 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 |
The HTTP client provides APIs to connect to, and communicate with, HTTP Servers.
To use the HTTPClient APIs, the application should include its header file as follows:
And, add the following HTTP library to the link line:
#define HTTPClient_DOMAIN_BUFLEN (100) |
#define HTTPClient_RES_HFIELD_BUFFER_SIZE (300) |
Size of the buffer which is used to store response values
#define HTTPClient_MIN_USER_WORKSPACE_SIZE (500) |
Minimum workspace size user should alloc in order to create client handle
#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) |
Age
HTTP response header
The HTTP standard response header containing the string Age
#define HTTPClient_HFIELD_RES_ALLOW (1) |
Allow
HTTP response header
The HTTP standard response header containing the string Allow
#define HTTPClient_HFIELD_RES_CACHE_CONTROL (2) |
Cache-Control
HTTP response header
The HTTP standard response header containing the string Cache-Control
#define HTTPClient_HFIELD_RES_CONNECTION (3) |
Connection
HTTP response header
The HTTP standard response header containing the string Connection
#define HTTPClient_HFIELD_RES_CONTENT_ENCODING (4) |
Content-Encoding
HTTP response header
The HTTP standard response header containing the string Content-Encoding
#define HTTPClient_HFIELD_RES_CONTENT_LANGUAGE (5) |
Content-Language
HTTP response header
The HTTP standard response header containing the string Content-Language
#define HTTPClient_HFIELD_RES_CONTENT_LENGTH (6) |
Content-Length
HTTP response header
The HTTP standard response header containing the string Content-Length
#define HTTPClient_HFIELD_RES_CONTENT_LOCATION (7) |
Content-Location
HTTP response header
The HTTP standard response header containing the string Content-Location
#define HTTPClient_HFIELD_RES_CONTENT_RANGE (8) |
Content-Range
HTTP response header
The HTTP standard response header containing the string Content-Range
#define HTTPClient_HFIELD_RES_CONTENT_TYPE (9) |
Content-Type
HTTP response header
The HTTP standard response header containing the string Content-Type
#define HTTPClient_HFIELD_RES_DATE (10) |
Date
HTTP response header
The HTTP standard response header containing the string Date
#define HTTPClient_HFIELD_RES_ETAG (11) |
ETag
HTTP response header
The HTTP standard response header containing the string ETag
#define HTTPClient_HFIELD_RES_EXPIRES (12) |
Expires
HTTP response header
The HTTP standard response header containing the string Expires
#define HTTPClient_HFIELD_RES_LAST_MODIFIED (13) |
Last-Modified
HTTP response header
The HTTP standard response header containing the string Last-Modified
#define HTTPClient_HFIELD_RES_LOCATION (14) |
Location
HTTP response header
The HTTP standard response header containing the string Location
#define HTTPClient_HFIELD_RES_PROXY_AUTHENTICATE (15) |
Proxy-Authenticate
HTTP response header
The HTTP standard response header containing the string Proxy-Authenticate
#define HTTPClient_HFIELD_RES_RETRY_AFTER (16) |
Retry-After
HTTP response header
The HTTP standard response header containing the string Retry-After
#define HTTPClient_HFIELD_RES_SERVER (17) |
Server
HTTP response header
The HTTP standard response header containing the string Server
#define HTTPClient_HFIELD_RES_SET_COOKIE (18) |
Set-Cookie
HTTP response header
The HTTP standard response header containing the string Set-Cookie
#define HTTPClient_HFIELD_RES_TRAILER (19) |
Trailer
HTTP response header
The HTTP standard response header containing the string Trailer
#define HTTPClient_HFIELD_RES_TRANSFER_ENCODING (20) |
Transfer-Encoding
HTTP response header
The HTTP standard response header containing the string Transfer-Encoding
#define HTTPClient_HFIELD_RES_UPGRADE (21) |
Upgrade
HTTP response header
The HTTP standard response header containing the string Upgrade
#define HTTPClient_HFIELD_RES_VARY (22) |
Vary
HTTP response header
The HTTP standard response header containing the string Vary
#define HTTPClient_HFIELD_RES_VIA (23) |
Via
HTTP response header
The HTTP standard response header containing the string Via
#define HTTPClient_HFIELD_RES_WWW_AUTHENTICATE (24) |
Www-Authenticate
HTTP response header
The HTTP standard response header containing the string Www-Authenticate
#define HTTPClient_HFIELD_RES_WARNING (25) |
Warning
HTTP response header
The HTTP standard response header containing the string Warning
#define HTTPClient_REQUEST_HEADER_MASK (0x80000000) |
#define HTTPClient_HFIELD_REQ_ACCEPT (26 | HTTPClient_REQUEST_HEADER_MASK) |
Accept
HTTP request header
The HTTP standard request header containing the string Accept
#define HTTPClient_HFIELD_REQ_ACCEPT_CHARSET (27 | HTTPClient_REQUEST_HEADER_MASK) |
Accept-Charset
HTTP request header
The HTTP standard request header containing the string Accept-Charset
#define HTTPClient_HFIELD_REQ_ACCEPT_ENCODING (28 | HTTPClient_REQUEST_HEADER_MASK) |
Accept-Encoding
HTTP request header
The HTTP standard request header containing the string Accept-Encoding
#define HTTPClient_HFIELD_REQ_ACCEPT_LANGUAGE (29 | HTTPClient_REQUEST_HEADER_MASK) |
Accept-Language
HTTP request header
The HTTP standard request header containing the string Accept-Language
#define HTTPClient_HFIELD_REQ_ALLOW (HTTPClient_HFIELD_RES_ALLOW | HTTPClient_REQUEST_HEADER_MASK) |
Allow
HTTP request header
The HTTP standard request header containing the string Allow
#define HTTPClient_HFIELD_REQ_AUTHORIZATION (30 | HTTPClient_REQUEST_HEADER_MASK) |
Authorization
HTTP request header
The HTTP standard request header containing the string Authorization
#define HTTPClient_HFIELD_REQ_CACHE_CONTROL (HTTPClient_HFIELD_RES_CACHE_CONTROL | HTTPClient_REQUEST_HEADER_MASK) |
Cache-Control
HTTP request header
The HTTP standard request header containing the string Cache-Control
#define HTTPClient_HFIELD_REQ_CONNECTION (HTTPClient_HFIELD_RES_CONNECTION | HTTPClient_REQUEST_HEADER_MASK) |
Connection
HTTP request header
The HTTP standard request header containing the string Connection
#define HTTPClient_HFIELD_REQ_CONTENT_ENCODING (HTTPClient_HFIELD_RES_CONTENT_ENCODING | HTTPClient_REQUEST_HEADER_MASK) |
Content-Encoding
HTTP request header
The HTTP standard request header containing the string Content-Encoding
#define HTTPClient_HFIELD_REQ_CONTENT_LANGUAGE (HTTPClient_HFIELD_RES_CONTENT_LANGUAGE | HTTPClient_REQUEST_HEADER_MASK) |
Content-Language
HTTP request header
The HTTP standard request header containing the string Content-Language
#define HTTPClient_HFIELD_REQ_CONTENT_LOCATION (HTTPClient_HFIELD_RES_CONTENT_LOCATION | HTTPClient_REQUEST_HEADER_MASK) |
Location
HTTP request header
The HTTP standard request header containing the string Location
#define HTTPClient_HFIELD_REQ_CONTENT_TYPE (HTTPClient_HFIELD_RES_CONTENT_TYPE | HTTPClient_REQUEST_HEADER_MASK) |
Content-Type
HTTP request header
The HTTP standard request header containing the string Content-Type
#define HTTPClient_HFIELD_REQ_COOKIE (31 | HTTPClient_REQUEST_HEADER_MASK) |
Cookie
HTTP request header
The HTTP standard request header containing the string Cookie
#define HTTPClient_HFIELD_REQ_DATE (HTTPClient_HFIELD_RES_DATE | HTTPClient_REQUEST_HEADER_MASK) |
Date
HTTP request header
The HTTP standard request header containing the string Date
#define HTTPClient_HFIELD_REQ_EXPECT (32 | HTTPClient_REQUEST_HEADER_MASK) |
Expect
HTTP request header
The HTTP standard request header containing the string Expect
#define HTTPClient_HFIELD_REQ_FORWARDED (33 | HTTPClient_REQUEST_HEADER_MASK) |
Forwarded
HTTP request header
The HTTP standard request header containing the string Forwarded
#define HTTPClient_HFIELD_REQ_FROM (34 | HTTPClient_REQUEST_HEADER_MASK) |
From
HTTP request header
The HTTP standard request header containing the string From
#define HTTPClient_HFIELD_REQ_HOST (35 | HTTPClient_REQUEST_HEADER_MASK) |
Host
HTTP request header
The HTTP standard request header containing the string Host
#define HTTPClient_HFIELD_REQ_IF_MATCH (36 | HTTPClient_REQUEST_HEADER_MASK) |
If-Match
HTTP request header
The HTTP standard request header containing the string If-Match
#define HTTPClient_HFIELD_REQ_IF_MODIFIED_SINCE (37 | HTTPClient_REQUEST_HEADER_MASK) |
If-Modified-Since
HTTP request header
The HTTP standard request header containing the string If-Modified-Since
#define HTTPClient_HFIELD_REQ_IF_NONE_MATCH (38 | HTTPClient_REQUEST_HEADER_MASK) |
If-None-Match
HTTP request header
The HTTP standard request header containing the string If-None-Match
#define HTTPClient_HFIELD_REQ_IF_RANGE (39 | HTTPClient_REQUEST_HEADER_MASK) |
If-Range
HTTP request header
The HTTP standard request header containing the string If-Range
#define HTTPClient_HFIELD_REQ_IF_UNMODIFIED_SINCE (40 | HTTPClient_REQUEST_HEADER_MASK) |
If-Unmodified-Since
HTTP request header
The HTTP standard request header containing the string If-Unmodified-Since
#define HTTPClient_HFIELD_REQ_ORIGIN (41 | HTTPClient_REQUEST_HEADER_MASK) |
Origin
HTTP request header
The HTTP standard request header containing the string Origin
#define HTTPClient_HFIELD_REQ_PROXY_AUTHORIZATION (42 | HTTPClient_REQUEST_HEADER_MASK) |
Proxy-Authorization
HTTP request header
The HTTP standard request header containing the string Proxy-Authorization
#define HTTPClient_HFIELD_REQ_RANGE (43 | HTTPClient_REQUEST_HEADER_MASK) |
Range
HTTP request header
The HTTP standard request header containing the string Range
#define HTTPClient_HFIELD_REQ_TE (44 | HTTPClient_REQUEST_HEADER_MASK) |
TE
HTTP request header
The HTTP standard request header containing the string TE
#define HTTPClient_HFIELD_REQ_TRANSFER_ENCODING (HTTPClient_HFIELD_RES_TRANSFER_ENCODING | HTTPClient_REQUEST_HEADER_MASK) |
Transfer-Encoding
HTTP request header
The HTTP standard request header containing the string Transfer-Encoding
#define HTTPClient_HFIELD_REQ_UPGRADE (HTTPClient_HFIELD_RES_UPGRADE | HTTPClient_REQUEST_HEADER_MASK) |
Upgrade
HTTP request header
The HTTP standard request header containing the string Upgrade
#define HTTPClient_HFIELD_REQ_USER_AGENT (45 | HTTPClient_REQUEST_HEADER_MASK) |
User-Agent
HTTP request header
The HTTP standard request header containing the string User-Agent
#define HTTPClient_HFIELD_REQ_VIA (HTTPClient_HFIELD_RES_VIA | HTTPClient_REQUEST_HEADER_MASK) |
Via
HTTP request header
The HTTP standard request header containing the string Via
#define HTTPClient_HFIELD_REQ_WARNING (HTTPClient_HFIELD_RES_WARNING | HTTPClient_REQUEST_HEADER_MASK) |
Warning
HTTP request header
The HTTP standard request header containing the string Warning
#define HTTPClient_MAX_NUMBER_OF_HEADER_FIELDS (46) |
#define HTTPClient_REDIRECT_FEATURE (48) |
Enable / Disable redirect feature
#define HTTPClient_RESPONSE_FILTER_CLEAR (49) |
Clear response filter to default(all enabled)
#define HTTPClient_REDIRECT_TLS_DOWNGRADE (50) |
Enable / Disable the option for tls downgrade
#define HTTPClient_AUTHENTICATE_SERVER_CALLBACK (51) |
Attaches callback which will handle the server authentication response (401)
#define HTTPClient_ESENDBUFSMALL (-3001) |
Internal send buffer is not big enough.
Define HTTPClient_BUF_LEN in httpclient_internal.h and rebuild the library.
#define HTTPClient_EGETOPTBUFSMALL (-3002) |
Buffer inserted into HTTPClient_getOpt() is not big enough.
#define HTTPClient_ERESPONSEINVALID (-3003) |
Response received from the server is not a valid HTTP/1.1 or HTTP/1.0 response.
#define HTTPClient_EINPROGRESS (-3004) |
Operation could not be completed. Try again.
#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.
#define HTTPClient_ECBALLOCATIONFAILED (-3006) |
Allocation failed during the CB creation.
Check whether there is free memory for CB allocation.
#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.
#define HTTPClient_ENULLPOINTER (-3009) |
Invalid de-referencing a NULL pointer.
Check that a NULL pointer wasn't dereferenced in the function.
#define HTTPClient_EREQUESTHEADERALLOCFAILED (-3010) |
Request header allocation failed.
#define HTTPClient_EREQHEADERNOTFOUND (-3011) |
Request header wasn't found in the req header list.
#define HTTPClient_EHOSTNOTFOUND (-3012) |
Host request header wasn't found.
Host header-field is mandatory.
#define HTTPClient_ECLIENTALREADYCONNECTED (-3013) |
Client is already connected.
#define HTTPClient_ERESPONSEISNOTREDIRECTABLE (-3014) |
Response is not redirectable.
#define HTTPClient_ESENDERROR (-3015) |
Send couldn't be completed.
#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.
#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()
#define HTTPClient_EWRONGAPIPARAMETER (-3018) |
Wrong API parameter.
Wrong parameter entered into the API.
#define HTTPClient_EHOSTHEADERALREADYEXIST (-3019) |
HOST already exist.
Host header is already exist, having multiple Host headers is invalid. Remove the existing host Header.
#define HTTPClient_ENOCONNECTION (-3020) |
Client is disconnected.
SlNetSock_recv return 0 which means the client is disconnected.
#define HTTPClient_ENOTABSOLUTEURI (-3021) |
URI is not absolute.
When Host header is not found, reconnection can be established only with absolute URI.
#define HTTPClient_ECANTCREATESECATTRIB (-3022) |
Error during creation of security attribute.
Error occured during the creationg of security attribue
#define HTTPClient_EINTERNAL (-3023) |
General internal error.
Error occured during processing in the HTTP Client library
#define HTTPClient_EGETCUSOMHEADERBUFSMALL (-3024) |
Buffer inserted into HTTPClient_getHeaderByName(..) is not big enough.
#define HTTPClient_ENOHEADERNAMEDASINSERTED (-3025) |
Custom response header name on HTTPClient_getHeaderByName(..) dosn't set before.
#define HTTPClient_IGNORE_PROXY (0x01) |
If proxy is set, this flag makes the connection without the proxy
#define HTTPClient_HOST_EXIST (0x02) |
If the user already added "Host:" header, set this flag
#define HTTPClient_HFIELD_NOT_PERSISTENT (0x01) |
Header Field added is not persistent
#define HTTPClient_HFIELD_PERSISTENT (0x02) |
Header Field added is persistent
#define HTTPClient_CUSTOM_RESPONSE_HEADER (0x01) |
Header Field for add or remove custom response header on setHeaderByName
#define HTTPClient_CHUNK_START (0x01) |
Header field indicate of remove requested name header Sets the client's request state into chunked body
#define HTTPClient_CHUNK_END (0x02) |
Sets the client's request state out of chunked body and sends last chunk
#define HTTPClient_DROP_BODY (0x04) |
Flushes the response body
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.
[in] | serverAuthBuff | Buffer containing authentication information (Www-Authenticate response header) received from server. |
[in] | serverAuthLen | Server authentication buffer length. |
[out] | clientAuthBuff | Buffer containing Authorization request header. |
[in,out] | clientAuthLen | Input 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. |
typedef void* HTTPClient_Handle |
HTTPClient_Handle HTTPClient_create | ( | int16_t * | status, |
void * | params | ||
) |
Allocate and initialize a new HTTPClient instance object and return its handle.
[out] | status | pointer to return status |
[in] | params | Special parameters for creating the instance (currently there are no special parameters) |
int16_t HTTPClient_destroy | ( | HTTPClient_Handle | client | ) |
Destroy the HTTP client instance and free the previously allocated instance object.
[in] | client | Pointer to the HTTP client instance |
int16_t HTTPClient_connect2 | ( | HTTPClient_Handle | client, |
const char * | hostName, | ||
SlNetSockSecAttrib_t * | secAttribs, | ||
uint32_t | flags, | ||
int16_t * | secureRetVal | ||
) |
Open a connection to an HTTP server. A user can connect to a HTTP server using TLS, proxy or both. HTTPClient_connect2 allows the user more control over security by accepting a secure attribute object and returning the value of the attempted secure connection.
[in] | client | Instance of an HTTP client |
[in] | hostName | IP address or URL of the HTTP server. |
[in] | secAttribs | A secure attributes object for configuring security. |
[in] | flags | Special flags for connection:
|
[out] | secureRetVal | Optional - If an error occurred while establishing a secure connection, the error code will be contained here. NULL should be passed if this is not desired. |
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.
[in] | client | Instance of an HTTP client |
[in] | hostName | IP address or URL of the HTTP server. |
[in] | exSecParams | Optional - External parameters for configuring security. |
[in] | flags | Special flags for connection:
|
int16_t HTTPClient_disconnect | ( | HTTPClient_Handle | client | ) |
Disconnect from the HTTP server.
[in] | client | Instance of the HTTP client |
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.
[in] | client | Instance of an HTTP client. |
[in] | method | HTTP method. |
[in] | requestURI | The path on the server to open. |
[in] | body | The body the user wishes to send in in the request, The body can be chunked or one body buffer. |
[in] | bodyLen | Length of the body sent in the request. |
[in] | flags | Special flags when the user wishes not to use the default settings.
|
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().
[in] | client | Instance of an HTTP client |
[out] | body | Response body buffer |
[in] | bodyLen | Length of response body buffer |
[out] | moreDataFlag | Set if more data is available |
moreDataFlag
will be false(All data was read).int16_t HTTPClient_setHeader | ( | HTTPClient_Handle | client, |
uint32_t | option, | ||
void * | value, | ||
uint32_t | len, | ||
uint32_t | flags | ||
) |
Setting HTTP Client Header-field configurations.
[in] | client | Instance of an HTTP client |
[in] | option | Options 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 un-filtered in a response. (if no request headers are set, all the headers will be available with size constraints) |
[in] | value | Value 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] | len | Length of the value. |
[in] | flags | Flags for settings need be one of the following:
|
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 supports request and response 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.
[in] | client | Instance of an HTTP client |
[in] | option | Options for setting could be one of the following: HTTPClient_REQUEST_HEADER_MASK - sets a header-field which will be used in requests. HTTPClient_CUSTOM_RESPONSE_HEADER - sets a header-field which will be used when HTTP response retrieve. This option need to be used when the user want to store custom response header by name. |
[in] | name | Name of header. Must be NULL-terminated. |
[in] | value | On request - Value for setting could be any related value for the corresponding header. On response - Must be NULL. |
[in] | len | On request - Length of the value. On response - Must be 0. |
[in] | flags | On request - Flags for settings need be one of the following:
|
int16_t HTTPClient_getHeader | ( | HTTPClient_Handle | client, |
uint32_t | option, | ||
void * | value, | ||
uint32_t * | len, | ||
uint32_t | flags | ||
) |
Getting HTTP Client Header-field configurations.
[in] | client | Instance of an HTTP client |
[in] | option | Options for getting could be one of the following: -Header-Fields ID -Response - headers - getting response headers-field value (only if value was set previously, and asked to be stored using another HTTPClient API). |
[out] | value | Value for getting, could be any related value for the corresponding option. |
[in,out] | len | Inputs Length of the value and output the actual length. |
[in] | flags | Flags for getting special configurations. |
int16_t HTTPClient_getHeaderByName | ( | HTTPClient_Handle | client, |
uint32_t | option, | ||
const char * | name, | ||
void * | value, | ||
uint32_t * | len, | ||
uint32_t | flags | ||
) |
Getting HTTP Client Header-field configurations. This API doesn't support removing existing custom header name, to do so please close the HTTPClient and reallocate it. This API for now, supports only custom 'response' headers.
[in] | client | Instance of an HTTP client. 'client' - cannot be NULL. |
[in] | option | Options for getting could be one of the following: -Response - headers - getting custom response headers-field value (only if value was set previously and asked to be stored using HTTPClient_setHeaderByName). #HTTPClient_CUSTOM_RESPONSE_HEADER |
[in] | name | Should contain the requested custom response header name for retrieve the appropriate value stored on the last HTTP response. 'name' cannot be NULL. |
[out] | value | Pointer value for store the appropriate value on the last HTTP response respectively to requested 'name' - will be copied into the pointer. 'value' cannot be NULL. |
[in,out] | len | Inputs Length of the value buffer size and output the actual inserted custom response header value length. 'len' cannot be 0. |
[in] | flags | Flags for getting special configurations - right now not in use. |
int16_t HTTPClient_setOpt | ( | HTTPClient_Handle | client, |
uint32_t | option, | ||
void * | value, | ||
uint32_t | len, | ||
uint32_t | flags | ||
) |
Setting HTTP Client configurations.
[in] | client | Instance of an HTTP client |
[in] | option | Options for setting could be one of the following: -Client instance parameters:
|
[in] | value | Value for setting could be any related value for the corresponding option. |
[in] | len | Length of the value. |
[in] | flags | Flags for settings special configurations. |
int16_t HTTPClient_getOpt | ( | HTTPClient_Handle | client, |
uint32_t | option, | ||
void * | value, | ||
uint32_t * | len, | ||
uint32_t | flags | ||
) |
Getting HTTP Client configurations.
[in] | client | Instance of an HTTP client |
[in] | option | Options for getting client settings. |
[out] | value | Value for getting, could be any related value for the corresponding option. |
[in,out] | len | Inputs Length of the value and output the actual length. |
[in] | flags | Flags for getting special configurations |
void HTTPClient_setProxy | ( | const SlNetSock_Addr_t * | addr | ) |
Uses the http CONNECT method to create a tunnel through a remote proxy server to the host designated in HTTPClient_connect.
[in] | addr | Pointer to SlNetSock_Addr_t struct containing ip and port number of proxy server |
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 |