32 #ifndef ti_net_http_HTTPCli__include
33 #define ti_net_http_HTTPCli__include
280 #include <ti/net/network.h>
282 #include <ti/net/http/ssock.h>
288 #ifndef HTTPCli_BUF_LEN
289 #define HTTPCli_BUF_LEN 128
301 #define HTTPCli_ESOCKETFAIL (-101)
308 #define HTTPCli_ECONNECTFAIL (-102)
315 #define HTTPCli_ESENDFAIL (-103)
322 #define HTTPCli_ERECVFAIL (-104)
329 #define HTTPCli_ETLSFAIL (-105)
334 #define HTTPCli_EHOSTNAME (-106)
342 #define HTTPCli_ESENDBUFSMALL (-107)
350 #define HTTPCli_ERECVBUFSMALL (-108)
355 #define HTTPCli_EASYNCMODE (-109)
360 #define HTTPCli_ETHREADFAIL (-110)
365 #define HTTPCli_EPROXYTUNNELFAIL (-111)
370 #define HTTPCli_ERESPONSEINVALID (-112)
378 #define HTTPCli_ECONTENTLENLARGE (-114)
386 #define HTTPCli_EREDIRECTURILONG (-115)
391 #define HTTPCli_ECONTENTTYPELONG (-116)
399 #define HTTPCli_ENOCONTENTCALLBACK (-117)
404 #define HTTPCli_ENOTCHUNKDATA (-118)
409 #define HTTPCli_EINPROGRESS (-119)
414 #define HTTPCli_EINTERNALBUFSMALL (-120)
419 #define HTTPCli_ESETNOTIFYFAIL (-121)
427 #define HTTPCli_EURILENLONG (-122)
436 #define HTTPCli_EHOSTFIELDNOTFOUND (-123)
439 #ifdef ti_net_http_HTTPCli__deprecated
444 #define HTTP_PORT HTTPStd_PORT
445 #define HTTPS_PORT HTTPStd_SECURE_PORT
448 #define HTTP_CONTINUE HTTPStd_CONTINUE
449 #define HTTP_SWITCHING_PROTOCOLS HTTPStd_SWITCHING_PROTOCOLS
450 #define HTTP_OK HTTPStd_OK
451 #define HTTP_CREATED HTTPStd_CREATED
452 #define HTTP_ACCEPTED HTTPStd_ACCEPTED
453 #define HTTP_NON_AUTHORITATIVE_INFORMATION HTTPStd_NON_AUTHORITATIVE_INFORMATION
454 #define HTTP_NO_CONTENT HTTPStd_NO_CONTENT
455 #define HTTP_RESET_CONTENT HTTPStd_RESET_CONTENT
456 #define HTTP_PARTIAL_CONTENT HTTPStd_PARTIAL_CONTENT
457 #define HTTP_MULTIPLE_CHOICES HTTPStd_MULTIPLE_CHOICES
458 #define HTTP_MOVED_PERMANENTLY HTTPStd_MOVED_PERMANENTLY
459 #define HTTP_FOUND HTTPStd_FOUND
460 #define HTTP_SEE_OTHER HTTPStd_SEE_OTHER
461 #define HTTP_NOT_MODIFIED HTTPStd_NOT_MODIFIED
462 #define HTTP_USE_PROXY HTTPStd_USE_PROXY
463 #define HTTP_TEMPORARY_REDIRECT HTTPStd_TEMPORARY_REDIRECT
464 #define HTTP_BAD_REQUEST HTTPStd_BAD_REQUEST
465 #define HTTP_UNAUTHORIZED HTTPStd_UNAUTHORIZED
466 #define HTTP_PAYMENT_REQUIRED HTTPStd_PAYMENT_REQUIRED
467 #define HTTP_FORBIDDEN HTTPStd_FORBIDDEN
468 #define HTTP_NOT_FOUND HTTPStd_NOT_FOUND
469 #define HTTP_METHOD_NOT_ALLOWED HTTPStd_METHOD_NOT_ALLOWED
470 #define HTTP_NOT_ACCEPTABLE HTTPStd_NOT_ACCEPTABLE
471 #define HTTP_PROXY_AUTHENTICATION_REQUIRED HTTPStd_PROXY_AUTHENTICATION_REQUIRED
472 #define HTTP_REQUEST_TIMEOUT HTTPStd_REQUEST_TIMEOUT
473 #define HTTP_CONFLICT HTTPStd_CONFLICT
474 #define HTTP_GONE HTTPStd_GONE
475 #define HTTP_LENGTH_REQUIRED HTTPStd_LENGTH_REQUIRED
476 #define HTTP_PRECONDITION_FAILED HTTPStd_PRECONDITION_FAILED
477 #define HTTP_REQUEST_ENTITY_TOO_LARGE HTTPStd_REQUEST_ENTITY_TOO_LARGE
478 #define HTTP_REQUEST_URI_TOO_LONG HTTPStd_REQUEST_URI_TOO_LONG
479 #define HTTP_UNSUPPORTED_MEDIA_TYPE HTTPStd_UNSUPPORTED_MEDIA_TYPE
480 #define HTTP_REQUESTED_RANGE_NOT_SATISFAIABLE \
481 HTTPStd_REQUESTED_RANGE_NOT_SATISFAIABLE
482 #define HTTP_EXPECTATION_FAILED HTTPStd_EXPECTATION_FAILED
483 #define HTTP_INTERNAL_SERVER_ERROR HTTPStd_INTERNAL_SERVER_ERROR
484 #define HTTP_NOT_IMPLEMENTED HTTPStd_NOT_IMPLEMENTED
485 #define HTTP_BAD_GATEWAY HTTPStd_BAD_GATEWAY
486 #define HTTP_SERVICE_UNAVAILABLE HTTPStd_SERVICE_UNAVAILABLE
487 #define HTTP_GATEWAY_TIMEOUT HTTPStd_GATEWAY_TIMEOUT
488 #define HTTP_HTTP_VERSION_NOT_SUPPORTED HTTPStd_HTTP_VERSION_NOT_SUPPORTED
491 #define HTTPCli_METHOD_GET HTTPStd_GET
492 #define HTTPCli_METHOD_POST HTTPStd_POST
493 #define HTTPCli_METHOD_HEAD HTTPStd_HEAD
494 #define HTTPCli_METHOD_OPTIONS HTTPStd_OPTIONS
495 #define HTTPCli_METHOD_PUT HTTPStd_PUT
496 #define HTTPCli_METHOD_DELETE HTTPStd_DELETE
497 #define HTTPCli_METHOD_CONNECT HTTPStd_CONNECT
500 #define HTTPCli_FIELD_NAME_ACCEPT HTTPStd_FIELD_NAME_ACCEPT
501 #define HTTPCli_FIELD_NAME_ACCEPT_CHARSET HTTPStd_FIELD_NAME_ACCEPT_CHARSET
502 #define HTTPCli_FIELD_NAME_ACCEPT_ENCODING HTTPStd_FIELD_NAME_ACCEPT_ENCODING
503 #define HTTPCli_FIELD_NAME_ACCEPT_LANGUAGE HTTPStd_FIELD_NAME_ACCEPT_LANGUAGE
504 #define HTTPCli_FIELD_NAME_ACCEPT_RANGES HTTPStd_FIELD_NAME_ACCEPT_RANGES
505 #define HTTPCli_FIELD_NAME_AGE HTTPStd_FIELD_NAME_AGE
506 #define HTTPCli_FIELD_NAME_ALLOW HTTPStd_FIELD_NAME_ALLOW
507 #define HTTPCli_FIELD_NAME_AUTHORIZATION HTTPStd_FIELD_NAME_AUTHORIZATION
508 #define HTTPCli_FIELD_NAME_CACHE_CONTROL HTTPStd_FIELD_NAME_CACHE_CONTROL
509 #define HTTPCli_FIELD_NAME_CONNECTION HTTPStd_FIELD_NAME_CONNECTION
510 #define HTTPCli_FIELD_NAME_CONTENT_ENCODING HTTPStd_FIELD_NAME_CONTENT_ENCODING
511 #define HTTPCli_FIELD_NAME_CONTENT_LANGUAGE HTTPStd_FIELD_NAME_CONTENT_LANGUAGE
512 #define HTTPCli_FIELD_NAME_CONTENT_LENGTH HTTPStd_FIELD_NAME_CONTENT_LENGTH
513 #define HTTPCli_FIELD_NAME_CONTENT_LOCATION HTTPStd_FIELD_NAME_CONTENT_LOCATION
514 #define HTTPCli_FIELD_NAME_CONTENT_MD5 HTTPStd_FIELD_NAME_CONTENT_MD5
515 #define HTTPCli_FIELD_NAME_CONTENT_RANGE HTTPStd_FIELD_NAME_CONTENT_RANGE
516 #define HTTPCli_FIELD_NAME_CONTENT_TYPE HTTPStd_FIELD_NAME_CONTENT_TYPE
517 #define HTTPCli_FIELD_NAME_COOKIE HTTPStd_FIELD_NAME_COOKIE
518 #define HTTPCli_FIELD_NAME_DATE HTTPStd_FIELD_NAME_DATE
519 #define HTTPCli_FIELD_NAME_ETAG HTTPStd_FIELD_NAME_ETAG
520 #define HTTPCli_FIELD_NAME_EXPECT HTTPStd_FIELD_NAME_EXPECT
521 #define HTTPCli_FIELD_NAME_EXPIRES HTTPStd_FIELD_NAME_EXPIRES
522 #define HTTPCli_FIELD_NAME_FROM HTTPStd_FIELD_NAME_FROM
523 #define HTTPCli_FIELD_NAME_HOST HTTPStd_FIELD_NAME_HOST
524 #define HTTPCli_FIELD_NAME_IF_MATCH HTTPStd_FIELD_NAME_IF_MATCH
525 #define HTTPCli_FIELD_NAME_IF_MODIFIED_SINCE \
526 HTTPStd_FIELD_NAME_IF_MODIFIED_SINCE
527 #define HTTPCli_FIELD_NAME_IF_NONE_MATCH HTTPStd_FIELD_NAME_IF_NONE_MATCH
528 #define HTTPCli_FIELD_NAME_IF_RANGE HTTPStd_FIELD_NAME_IF_RANGE
529 #define HTTPCli_FIELD_NAME_IF_UNMODIFIED_SINCE \
530 HTTPStd_FIELD_NAME_IF_UNMODIFIED_SINCE
531 #define HTTPCli_FIELD_NAME_LAST_MODIFIED HTTPStd_FIELD_NAME_LAST_MODIFIED
532 #define HTTPCli_FIELD_NAME_LOCATION HTTPStd_FIELD_NAME_LOCATION
533 #define HTTPCli_FIELD_NAME_MAX_FORWARDS HTTPStd_FIELD_NAME_MAX_FORWARDS
534 #define HTTPCli_FIELD_NAME_ORIGIN HTTPStd_FIELD_NAME_ORIGIN
535 #define HTTPCli_FIELD_NAME_PRAGMA HTTPStd_FIELD_NAME_PRAGMA
536 #define HTTPCli_FIELD_NAME_PROXY_AUTHENTICATE \
537 HTTPStd_FIELD_NAME_PROXY_AUTHENTICATE
538 #define HTTPCli_FIELD_NAME_PROXY_AUTHORIZATION \
539 HTTPStd_FIELD_NAME_PROXY_AUTHORIZATION
540 #define HTTPCli_FIELD_NAME_RANGE HTTPStd_FIELD_NAME_RANGE
541 #define HTTPCli_FIELD_NAME_REFERER HTTPStd_FIELD_NAME_REFERER
542 #define HTTPCli_FIELD_NAME_RETRY_AFTER HTTPStd_FIELD_NAME_RETRY_AFTER
543 #define HTTPCli_FIELD_NAME_SERVER HTTPStd_FIELD_NAME_SERVER
544 #define HTTPCli_FIELD_NAME_TE HTTPStd_FIELD_NAME_TE
545 #define HTTPCli_FIELD_NAME_TRAILER HTTPStd_FIELD_NAME_TRAILER
546 #define HTTPCli_FIELD_NAME_TRANSFER_ENCODING \
547 HTTPStd_FIELD_NAME_TRANSFER_ENCODING
548 #define HTTPCli_FIELD_NAME_UPGRADE HTTPStd_FIELD_NAME_UPGRADE
549 #define HTTPCli_FIELD_NAME_USER_AGENT HTTPStd_FIELD_NAME_USER_AGENT
550 #define HTTPCli_FIELD_NAME_VARY HTTPStd_FIELD_NAME_VARY
551 #define HTTPCli_FIELD_NAME_VIA HTTPStd_FIELD_NAME_VIA
552 #define HTTPCli_FIELD_NAME_WWW_AUTHENTICATE HTTPStd_FIELD_NAME_WWW_AUTHENTICATE
553 #define HTTPCli_FIELD_NAME_WARNING HTTPStd_FIELD_NAME_WARNING
554 #define HTTPCli_FIELD_NAME_X_FORWARDED_FOR HTTPStd_FIELD_NAME_X_FORWARDED_FOR
562 #define HTTPCli_TYPE_TLS (0x02)
563 #define HTTPCli_TYPE_IPV6 (0x04)
571 #define HTTPCli_FIELD_ID_DUMMY (-11)
572 #define HTTPCli_FIELD_ID_END (-12)
617 int len,
bool moreFlag);
648 typedef void (*HTTPCli_Notify)(
long skt,
void *cli);
670 #ifndef HTTPCli_LIBTYPE_MIN
691 #ifndef HTTPCli_LIBTYPE_MIN
702 HTTPCli_Notify rnotify;
703 HTTPCli_Notify wnotify;
704 HTTPCli_Notify enotify;
766 extern int HTTPCli_connect(HTTPCli_Handle cli,
const struct sockaddr *addr,
821 const char *fields[]);
847 const char *requestURI,
bool moreFlag);
867 const char *value,
bool lastFlag);
923 int len,
bool *moreFlag);
946 int len,
bool *moreFlag);
HTTPCli_StatusHandler * shandle
Definition: httpcli.h:692
#define HTTPCli_BUF_LEN
Definition: httpcli.h:289
HTTPCli_ContentCallback handle
Definition: httpcli.h:624
HTTPCli_Field * HTTPCli_setRequestFields(HTTPCli_Handle cli, const HTTPCli_Field *fields)
Set an array of header fields to be sent for every HTTP request.
struct HTTPCli_Params HTTPCli_Params
HTTPCli instance paramaters.
HTTPCli_ContentHandler * chandle
Definition: httpcli.h:672
void HTTPCli_disconnect(HTTPCli_Handle cli)
Disconnect from the HTTP server and destroy the HTTP client instance.
HTTPCli_RedirectCallback rhandle
Definition: httpcli.h:673
struct HTTPCli_Struct HTTPCli_Struct
HTTPCli instance type.
struct HTTPCli_Field HTTPCli_Field
HTTPCli request header field.
Ssock_Struct ssock
Definition: httpcli.h:663
void HTTPCli_setProxy(const struct sockaddr *addr)
Set the proxy address.
unsigned long clen
Definition: httpcli.h:662
int HTTPCli_sendField(HTTPCli_Handle cli, const char *name, const char *value, bool lastFlag)
Send an header field to the HTTP server.
unsigned int state
Definition: httpcli.h:661
Standard Definitions for HTTP Status Codes, Content Type and Fields.
HTTPCli request header field.
Definition: httpcli.h:578
HTTPCli_StatusCallback handle1xx
Definition: httpcli.h:596
unsigned int priority
Definition: httpcli.h:697
int HTTPCli_sendRequestBody(HTTPCli_Handle cli, const char *body, int len)
Send the request message body to the HTTP server.
HTTPCli content handler type.
Definition: httpcli.h:622
HTTPCli_Struct * HTTPCli_Handle
Definition: httpcli.h:714
unsigned int stackSize
Definition: httpcli.h:696
int HTTPCli_getSocketError(HTTPCli_Handle cli)
Get the error code from the socket/TLS layer.
HTTPCli instance type.
Definition: httpcli.h:658
int(* HTTPCli_ContentCallback)(void *cli, int status, char *body, int len, bool moreFlag)
HTTPCli callback function for content handling.
Definition: httpcli.h:616
int timeout
Definition: httpcli.h:708
int HTTPCli_readRawResponseBody(HTTPCli_Handle cli, char *body, int len)
Read the raw response message body from the HTTP server.
int HTTPCli_initSockAddr(struct sockaddr *addr, const char *uri, int flags)
Initialize the socket address structure for the given URI.
int HTTPCli_connect(HTTPCli_Handle cli, const struct sockaddr *addr, int flags, const HTTPCli_Params *params)
Open a connection to an HTTP server.
void HTTPCli_destruct(HTTPCli_Struct *cli)
Destory the HTTP client instance.
HTTPCli_StatusCallback handle2xx
Definition: httpcli.h:597
char * bufptr
Definition: httpcli.h:668
HTTPCli_RedirectCallback rhandle
Definition: httpcli.h:694
char * contentType
Definition: httpcli.h:623
HTTPCli_StatusCallback handle4xx
Definition: httpcli.h:598
char ** respFields
Definition: httpcli.h:659
unsigned int stackSize
Definition: httpcli.h:675
const char * value
Definition: httpcli.h:580
unsigned int priority
Definition: httpcli.h:676
int sockerr
Definition: httpcli.h:660
int HTTPCli_sendRequest(HTTPCli_Handle cli, const char *method, const char *requestURI, bool moreFlag)
Make an HTTP 1.1 request to the HTTP server.
const char * name
Definition: httpcli.h:579
HTTPCli_ContentHandler * chandle
Definition: httpcli.h:693
int HTTPCli_getResponseStatus(HTTPCli_Handle cli)
Process the response header from the HTTP server and return status.
int HTTPCli_getResponseField(HTTPCli_Handle cli, char *value, int len, bool *moreFlag)
Process the response header from the HTTP server and return field.
HTTPCli instance paramaters.
Definition: httpcli.h:689
struct HTTPCli_StatusHandler HTTPCli_StatusHandler
HTTPCli response status code handler type.
char ** HTTPCli_setResponseFields(HTTPCli_Handle cli, const char *fields[])
Set the header fields to filter the response headers.
void(* HTTPCli_StatusCallback)(void *cli, int status)
HTTPCli callback function for status handling.
Definition: httpcli.h:590
HTTPCli response status code handler type.
Definition: httpcli.h:595
HTTPCli_Handle HTTPCli_create()
Allocate and initialize a new instance object and return its handle.
HTTPCli_Field * fields
Definition: httpcli.h:664
void HTTPCli_construct(HTTPCli_Struct *cli)
Create a new instance object in the provided structure.
HTTPCli_StatusHandler * shandle
Definition: httpcli.h:671
struct HTTPCli_ContentHandler HTTPCli_ContentHandler
HTTPCli content handler type.
void(* HTTPCli_RedirectCallback)(void *cli, int status, char *uri)
HTTPCli callback function prototype for redirection handling.
Definition: httpcli.h:636
char buf[HTTPCli_BUF_LEN]
Definition: httpcli.h:666
unsigned int buflen
Definition: httpcli.h:667
int HTTPCli_readResponseBody(HTTPCli_Handle cli, char *body, int len, bool *moreFlag)
Read the parsed response body data from the HTTP server.
void HTTPCli_delete(HTTPCli_Handle *cli)
Destory the HTTP client instance and free the previously allocated instance object.