257 #include <http/client/httpstd.h>
258 #include <http/client/network.h>
259 #include <http/client/ssock.h>
261 #ifndef HTTPCli_BUF_LEN
262 #define HTTPCli_BUF_LEN 128
265 #ifndef HTTPCli_CERT_NAME_LEN
266 #define HTTPCli_CERT_NAME_LEN 16
273 #define HTTPCli_ESOCKETFAIL (-101)
278 #define HTTPCli_ECONNECTFAIL (-102)
283 #define HTTPCli_ESENDFAIL (-103)
288 #define HTTPCli_ERECVFAIL (-104)
293 #define HTTPCli_ETLSFAIL (-105)
298 #define HTTPCli_EHOSTNAME (-106)
303 #define HTTPCli_ESENDBUFSMALL (-107)
308 #define HTTPCli_ERECVBUFSMALL (-108)
313 #define HTTPCli_EASYNCMODE (-109)
318 #define HTTPCli_ETHREADFAIL (-110)
323 #define HTTPCli_EPROXYTUNNELFAIL (-111)
328 #define HTTPCli_ERESPONSEINVALID (-112)
333 #define HTTPCli_ECONTENTLENLARGE (-114)
338 #define HTTPCli_EREDIRECTURILONG (-115)
343 #define HTTPCli_ECONTENTTYPELONG (-116)
348 #define HTTPCli_ENOCONTENTCALLBACK (-117)
353 #define HTTPCli_ENOTCHUNKDATA (-118)
358 #define HTTPCli_EINPROGRESS (-119)
363 #define HTTPCli_EINTERNALBUFSMALL (-120)
368 #define HTTPCli_ESETNOTIFYFAIL (-121)
373 #define HTTPCli_EURILENLONG (-120)
376 #define HTTPCli_METHOD_GET "GET"
377 #define HTTPCli_METHOD_POST "POST"
378 #define HTTPCli_METHOD_HEAD "HEAD"
379 #define HTTPCli_METHOD_OPTIONS "OPTIONS"
380 #define HTTPCli_METHOD_PUT "PUT"
381 #define HTTPCli_METHOD_DELETE "DELETE"
382 #define HTTPCli_METHOD_CONNECT "CONNECT"
385 #define HTTPCli_FIELD_NAME_ACCEPT "Accept"
386 #define HTTPCli_FIELD_NAME_ACCEPT_CHARSET "Accept-Charset"
387 #define HTTPCli_FIELD_NAME_ACCEPT_ENCODING "Accept-Encoding"
388 #define HTTPCli_FIELD_NAME_ACCEPT_LANGUAGE "Accept-Language"
389 #define HTTPCli_FIELD_NAME_ACCEPT_RANGES "Accept-Ranges"
390 #define HTTPCli_FIELD_NAME_AGE "Age"
391 #define HTTPCli_FIELD_NAME_ALLOW "Allow"
392 #define HTTPCli_FIELD_NAME_AUTHORIZATION "Authorization"
393 #define HTTPCli_FIELD_NAME_CACHE_CONTROL "Cache-Control"
394 #define HTTPCli_FIELD_NAME_CONNECTION "Connection"
395 #define HTTPCli_FIELD_NAME_CONTENT_ENCODING "Content-Encoding"
396 #define HTTPCli_FIELD_NAME_CONTENT_LANGUAGE "Content-Language"
397 #define HTTPCli_FIELD_NAME_CONTENT_LENGTH "Content-Length"
398 #define HTTPCli_FIELD_NAME_CONTENT_LOCATION "Content-Location"
399 #define HTTPCli_FIELD_NAME_CONTENT_MD5 "Content-MD5"
400 #define HTTPCli_FIELD_NAME_CONTENT_RANGE "Content-Range"
401 #define HTTPCli_FIELD_NAME_CONTENT_TYPE "Content-Type"
402 #define HTTPCli_FIELD_NAME_COOKIE "Cookie"
403 #define HTTPCli_FIELD_NAME_DATE "Date"
404 #define HTTPCli_FIELD_NAME_ETAG "ETag"
405 #define HTTPCli_FIELD_NAME_EXPECT "Expect"
406 #define HTTPCli_FIELD_NAME_EXPIRES "Expires"
407 #define HTTPCli_FIELD_NAME_FROM "From"
408 #define HTTPCli_FIELD_NAME_HOST "Host"
409 #define HTTPCli_FIELD_NAME_IF_MATCH "If-Match"
410 #define HTTPCli_FIELD_NAME_IF_MODIFIED_SINCE "If-Modified-Since"
411 #define HTTPCli_FIELD_NAME_IF_NONE_MATCH "If-None-Match"
412 #define HTTPCli_FIELD_NAME_IF_RANGE "If-Range"
413 #define HTTPCli_FIELD_NAME_IF_UNMODIFIED_SINCE "If-Unmodified-Since"
414 #define HTTPCli_FIELD_NAME_LAST_MODIFIED "Last-Modified"
415 #define HTTPCli_FIELD_NAME_LOCATION "Location"
416 #define HTTPCli_FIELD_NAME_MAX_FORWARDS "Max-Forwards"
417 #define HTTPCli_FIELD_NAME_ORIGIN "Origin"
418 #define HTTPCli_FIELD_NAME_PRAGMA "Pragma"
419 #define HTTPCli_FIELD_NAME_PROXY_AUTHENTICATE "Proxy-Authenticate"
420 #define HTTPCli_FIELD_NAME_PROXY_AUTHORIZATION "Proxy-Authorization"
421 #define HTTPCli_FIELD_NAME_RANGE "Range"
422 #define HTTPCli_FIELD_NAME_REFERER "Referer"
423 #define HTTPCli_FIELD_NAME_RETRY_AFTER "Retry-After"
424 #define HTTPCli_FIELD_NAME_SERVER "Server"
425 #define HTTPCli_FIELD_NAME_TE "TE"
426 #define HTTPCli_FIELD_NAME_TRAILER "Trailer"
427 #define HTTPCli_FIELD_NAME_TRANSFER_ENCODING "Transfer-Encoding"
428 #define HTTPCli_FIELD_NAME_UPGRADE "Upgrade"
429 #define HTTPCli_FIELD_NAME_USER_AGENT "User-Agent"
430 #define HTTPCli_FIELD_NAME_VARY "Vary"
431 #define HTTPCli_FIELD_NAME_VIA "Via"
432 #define HTTPCli_FIELD_NAME_WWW_AUTHENTICATE "WWW-Authenticate"
433 #define HTTPCli_FIELD_NAME_WARNING "Warning"
434 #define HTTPCli_FIELD_NAME_X_FORWARDED_FOR "X-Forwarded-For"
437 #define HTTPCli_TYPE_TLS (0x02)
438 #define HTTPCli_TYPE_IPV6 (0x04)
441 #define HTTPCli_FIELD_ID_DUMMY (-11)
442 #define HTTPCli_FIELD_ID_END (-12)
487 int len,
bool moreFlag);
532 #ifndef HTTPCli_LIBTYPE_MIN
537 unsigned int stackSize;
538 unsigned int priority;
549 #ifndef HTTPCli_LIBTYPE_MIN
577 #elif defined(__SL__)
578 SlSockSecureMethod method;
579 SlSockSecureMask mask;
580 char cafile[HTTPCli_CERT_NAME_LEN];
582 char privkey[HTTPCli_CERT_NAME_LEN];
584 char cert[HTTPCli_CERT_NAME_LEN];
586 char dhkey[HTTPCli_CERT_NAME_LEN];
703 const char *fields[]);
729 const char *requestURI,
bool moreFlag);
749 const char *value,
bool lastFlag);
805 int len,
bool *moreFlag);
828 int len,
bool *moreFlag);
struct HTTPCli_Struct HTTPCli_Struct
HTTPCli instance type.
HTTPCli_ContentCallback handle
Definition: httpcli.h:494
HTTPCli secure parameters for TLS.
Definition: httpcli.h:573
void HTTPCli_construct(HTTPCli_Struct *cli)
Create a new instance object in the provided structure.
void HTTPCli_delete(HTTPCli_Handle cli)
Destory the HTTP client instance and free the previously allocated instance object.
Definition: httpcli.c:1374
struct HTTPCli_StatusHandler HTTPCli_StatusHandler
HTTPCli Response status code handlers.
int HTTPCli_initSockAddr(struct sockaddr *addr, const char *uri, int flags)
Initialize the socket address structure for the given URI. Supported URI formats are: "http://www...
Definition: httpcli.c:1072
HTTPCli Request Header Field.
Definition: httpcli.h:447
HTTPCli_StatusCallback handle1xx
Definition: httpcli.h:466
unsigned int priority
Definition: httpcli.h:555
HTTPCli Content Handler type.
Definition: httpcli.h:492
struct HTTPCli_SecureParams HTTPCli_SecureParams
HTTPCli secure parameters for TLS.
int HTTPCli_getResponseStatus(HTTPCli_Handle cli)
Process the response header from the HTTP server and return status.
Definition: httpcli.c:1568
struct HTTPCli_Params HTTPCli_Params
HTTPCli instance paramaters.
HTTPCli_Field * HTTPCli_setRequestFields(HTTPCli_Handle cli, const HTTPCli_Field *fields)
Set an array of header fields to be sent for every HTTP request.
Definition: httpcli.c:1429
int HTTPCli_sendRequestBody(HTTPCli_Handle cli, const char *body, int len)
Send the request message body to the HTTP server.
Definition: httpcli.c:1551
unsigned int stackSize
Definition: httpcli.h:554
int HTTPCli_readRawResponseBody(HTTPCli_Handle cli, char *body, int len)
Read the raw response message body from the HTTP server.
Definition: httpcli.c:1707
HTTPCli instance type.
Definition: httpcli.h:521
#define HTTPCli_BUF_LEN
Definition: httpcli.h:262
int(* HTTPCli_ContentCallback)(void *cli, int status, char *body, int len, bool moreFlag)
HTTPCli callback function prototype for content handling.
Definition: httpcli.h:486
int timeout
Definition: httpcli.h:565
int HTTPCli_sendRequest(HTTPCli_Handle cli, const char *method, const char *requestURI, bool moreFlag)
Make a HTTP 1.1 request to the HTTP server.
Definition: httpcli.c:1474
int HTTPCli_connect(HTTPCli_Struct *cli, const struct sockaddr *addr, int flags, const HTTPCli_Params *params)
Open a connection to a HTTP server.
Definition: httpcli.c:1174
struct HTTPCli_Field HTTPCli_Field
HTTPCli Request Header Field.
void(* HTTPCli_RedirectCallback)(void *cli, int status, char *uri)
HTTPCli callback function prototype for redirection handling.
Definition: httpcli.h:506
int HTTPCli_sendField(HTTPCli_Handle cli, const char *name, const char *value, bool lastFlag)
Send a header field to the HTTP server.
Definition: httpcli.c:1515
void HTTPCli_destruct(HTTPCli_Struct *cli)
Destory the HTTP client instance.
Definition: httpcli.c:1386
HTTPCli_StatusCallback handle2xx
Definition: httpcli.h:467
int HTTPCli_readResponseBody(HTTPCli_Handle cli, char *body, int len, bool *moreFlag)
Read the parsed response body data from the HTTP server.
Definition: httpcli.c:1677
void HTTPCli_setSecureParams(HTTPCli_SecureParams *sparams)
Set the secure communication paramaters.
Definition: httpcli.c:1464
char * contentType
Definition: httpcli.h:493
HTTPCli_StatusCallback handle4xx
Definition: httpcli.h:468
void HTTPCli_setProxy(const struct sockaddr *addr)
Set the proxy address.
Definition: httpcli.c:1725
char ** HTTPCli_setResponseFields(HTTPCli_Handle cli, const char *fields[])
Set the header fields to filter the response headers.
Definition: httpcli.c:1447
void(* HTTPCli_StatusCallback)(void *cli, int status)
HTTPCli callback function prototype for status handling.
Definition: httpcli.h:460
const char * value
Definition: httpcli.h:449
const char * name
Definition: httpcli.h:448
HTTPCli instance paramaters.
Definition: httpcli.h:547
struct HTTPCli_ContentHandler HTTPCli_ContentHandler
HTTPCli Content Handler type.
void HTTPCli_disconnect(HTTPCli_Struct *cli)
Disconnect from the HTTP server and destroy the HTTP client instance.
Definition: httpcli.c:1413
HTTPCli_Handle HTTPCli_create()
Allocate and initialize a new instance object and return its handle.
Definition: httpcli.c:1359
HTTPCli Response status code handlers.
Definition: httpcli.h:465
int HTTPCli_getResponseField(HTTPCli_Handle cli, char *value, int len, bool *moreFlag)
Process the response header from the HTTP server and return field.
Definition: httpcli.c:1588
void(* HTTPCli_Notify)(long skt, void *cli)
HTTPCli callback function prototype for asynchronous notify Supported for 6LoWPAN stack only...
Definition: httpcli.h:516