coreHTTP
v2.0.2
HTTP/1.1 Client Library
|
|
Go to the documentation of this file.
28 #ifndef CORE_HTTP_CLIENT_H_
29 #define CORE_HTTP_CLIENT_H_
44 #ifndef HTTP_DO_NOT_USE_CUSTOM_CONFIG
45 #include "core_http_config.h"
60 #define HTTP_METHOD_GET "GET"
61 #define HTTP_METHOD_PUT "PUT"
62 #define HTTP_METHOD_POST "POST"
63 #define HTTP_METHOD_HEAD "HEAD"
71 #define HTTP_MAX_CONTENT_LENGTH_HEADER_LENGTH sizeof( "Content-Length: 4294967295" ) - 1U
90 #define HTTP_SEND_DISABLE_CONTENT_LENGTH_FLAG 0x1U
112 #define HTTP_REQUEST_KEEP_ALIVE_FLAG 0x1U
133 #define HTTP_RESPONSE_CONNECTION_CLOSE_FLAG 0x1U
141 #define HTTP_RESPONSE_CONNECTION_KEEP_ALIVE_FLAG 0x2U
155 #define HTTP_RANGE_REQUEST_END_OF_FILE -1
161 typedef enum HTTPStatus
328 typedef struct HTTPRequestHeaders
359 typedef struct HTTPRequestInfo
396 typedef struct HTTPClient_ResponseHeaderParsingCallback
407 void ( * onHeaderCallback )(
void * pContext,
408 const char * fieldLoc,
410 const char * valueLoc,
412 uint16_t statusCode );
433 typedef struct HTTPResponse
725 int32_t rangeStartOrlastNbytes,
827 const uint8_t * pRequestBodyBuf,
828 size_t reqBodyBufLen,
830 uint32_t sendFlags );
885 const char ** pValueLoc,
886 size_t * pValueLen );
@ HTTPSecurityAlertInvalidStatusCode
The server sent a response with an invalid character in the HTTP status-code or the HTTP status code ...
Definition: core_http_client.h:268
HTTPStatus_t HTTPClient_ReadHeader(const HTTPResponse_t *pResponse, const char *pField, size_t fieldLen, const char **pValueLoc, size_t *pValueLen)
Read a header from a buffer containing a complete HTTP response. This will return the location of the...
Definition: core_http_client.c:2496
@ HTTPNetworkError
A network error was returned from the transport interface.
Definition: core_http_client.h:193
@ HTTPHeaderNotFound
The requested header field was not found in the response buffer.
Definition: core_http_client.h:305
size_t contentLength
The value in the "Content-Length" header is returned here.
Definition: core_http_client.h:518
size_t bodyLen
Byte length of the body in pBuffer.
Definition: core_http_client.h:502
@ HTTPInsufficientMemory
The application buffer was not large enough for the HTTP request headers or the HTTP response message...
Definition: core_http_client.h:224
const uint8_t * pHeaders
The starting location of the response headers in pBuffer.
Definition: core_http_client.h:481
@ HTTPSuccess
The HTTP Client library function completed successfully.
Definition: core_http_client.h:173
@ HTTPNoResponse
No HTTP response was received from the network.
Definition: core_http_client.h:212
@ HTTPSecurityAlertInvalidProtocolVersion
The server sent a response with an invalid character in the HTTP protocol version.
Definition: core_http_client.h:259
HTTPStatus_t HTTPClient_InitializeRequestHeaders(HTTPRequestHeaders_t *pRequestHeaders, const HTTPRequestInfo_t *pRequestInfo)
Initialize the request headers, stored in HTTPRequestHeaders_t.pBuffer, with initial configurations f...
Definition: core_http_client.c:1557
@ HTTPInvalidParameter
The HTTP Client library function input an invalid parameter.
Definition: core_http_client.h:185
const uint8_t * pBody
The starting location of the response body in pBuffer.
Definition: core_http_client.h:495
const char * pPath
The Request-URI to the objects of interest, e.g. "/path/to/item.txt".
Definition: core_http_client.h:370
@ HTTPSecurityAlertResponseHeadersSizeLimitExceeded
The server sent more headers than the configured HTTP_MAX_RESPONSE_HEADERS_SIZE_BYTES.
Definition: core_http_client.h:233
HTTPStatus_t HTTPClient_AddRangeHeader(HTTPRequestHeaders_t *pRequestHeaders, int32_t rangeStartOrlastNbytes, int32_t rangeEnd)
Add the byte range request header to the request headers store in HTTPRequestHeaders_t....
Definition: core_http_client.c:1714
const char * pMethod
The HTTP request method e.g. "GET", "POST", "PUT", or "HEAD".
Definition: core_http_client.h:364
uint32_t reqFlags
Flags to activate other request header configurations.
Definition: core_http_client.h:386
uint32_t respFlags
Flags of useful headers found in the response.
Definition: core_http_client.h:533
The default values for the configuration macros for the HTTP Client library.
Represents an HTTP response.
Definition: core_http_client.h:434
size_t bufferLen
Definition: core_http_client.h:451
HTTPStatus_t HTTPClient_AddHeader(HTTPRequestHeaders_t *pRequestHeaders, const char *pField, size_t fieldLen, const char *pValue, size_t valueLen)
Add a header to the request headers stored in HTTPRequestHeaders_t.pBuffer.
Definition: core_http_client.c:1654
uint8_t * pBuffer
Buffer for both the raw HTTP header and body.
Definition: core_http_client.h:450
@ HTTPSecurityAlertExtraneousResponseData
A response contained the "Connection: close" header, but there was more data at the end of the comple...
Definition: core_http_client.h:242
size_t headersLen
Byte length of the response headers in pBuffer.
Definition: core_http_client.h:488
size_t hostLen
Definition: core_http_client.h:379
const char * HTTPClient_strerror(HTTPStatus_t status)
Error code to string conversion utility for HTTP Client library.
Definition: core_http_client.c:2561
HTTPStatus_t
The HTTP Client library return status.
Definition: core_http_client.h:162
HTTPClient_GetCurrentTimeFunc_t getTime
Optional callback for getting the system time.
Definition: core_http_client.h:474
@ HTTPParserInternalError
An error occurred in the third-party parsing library.
Definition: core_http_client.h:297
HTTPClient_ResponseHeaderParsingCallback_t * pHeaderParsingCallback
Optional callback for intercepting the header during the first parse through of the response as is it...
Definition: core_http_client.h:458
@ HTTPSecurityAlertInvalidCharacter
An invalid character was found in the HTTP response message or in the HTTP request header.
Definition: core_http_client.h:278
const char * pHost
The server's host name, e.g. "my-storage.my-cloud.com".
Definition: core_http_client.h:378
Configurations of the initial request headers.
Definition: core_http_client.h:360
@ HTTPSecurityAlertInvalidContentLength
The response contains either an invalid character in the Content-Length header or a Content-Length he...
Definition: core_http_client.h:288
size_t headerCount
Count of the headers sent by the server.
Definition: core_http_client.h:525
HTTPStatus_t HTTPClient_Send(const TransportInterface_t *pTransport, HTTPRequestHeaders_t *pRequestHeaders, const uint8_t *pRequestBodyBuf, size_t reqBodyBufLen, HTTPResponse_t *pResponse, uint32_t sendFlags)
Send the request headers in HTTPRequestHeaders_t.pBuffer and request body in pRequestBodyBuf over the...
Definition: core_http_client.c:2154
@ HTTPSecurityAlertInvalidChunkHeader
The server sent a chunk header containing an invalid character.
Definition: core_http_client.h:250
@ HTTPInvalidResponse
The HTTP response, provided for parsing, is either corrupt or incomplete.
Definition: core_http_client.h:314
@ HTTPPartialResponse
Part of the HTTP response was received from the network.
Definition: core_http_client.h:201
size_t methodLen
Definition: core_http_client.h:365
Transport interface definitions to send and receive data over the network.
size_t pathLen
Definition: core_http_client.h:371
uint16_t statusCode
The HTTP response Status-Code.
Definition: core_http_client.h:511
uint32_t(* HTTPClient_GetCurrentTimeFunc_t)(void)
Application provided function to query the current time in milliseconds.
Definition: core_http_client.h:427
The transport layer interface.
Definition: transport_interface.h:252