43
43
*/
44
44
static uint32_t getZeroTimestampMs ( void );
45
45
46
- /**
47
- * @brief Send HTTP bytes over the transport send interface.
48
- *
49
- * @param[in] pTransport Transport interface.
50
- * @param[in] getTimestampMs Function to retrieve a timestamp in milliseconds.
51
- * @param[in] pData HTTP request data to send.
52
- * @param[in] dataLen HTTP request data length.
53
- *
54
- * @return #HTTPSuccess if successful. If there was a network error or less
55
- * bytes than what were specified were sent, then #HTTPNetworkError is
56
- * returned.
57
- */
58
- static HTTPStatus_t sendHttpData ( const TransportInterface_t * pTransport ,
59
- HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
60
- const uint8_t * pData ,
61
- size_t dataLen );
62
46
63
- /**
64
- * @brief Send the HTTP headers over the transport send interface.
65
- *
66
- * @param[in] pTransport Transport interface.
67
- * @param[in] getTimestampMs Function to retrieve a timestamp in milliseconds.
68
- * @param[in] pRequestHeaders Request headers to send, it includes the buffer
69
- * and length.
70
- * @param[in] reqBodyLen The length of the request body to be sent. This is
71
- * used to generated a Content-Length header.
72
- * @param[in] sendFlags Application provided flags to #HTTPClient_Send.
73
- *
74
- * @return #HTTPSuccess if successful. If there was a network error or less
75
- * bytes than what were specified were sent, then #HTTPNetworkError is
76
- * returned.
77
- */
78
- static HTTPStatus_t sendHttpHeaders ( const TransportInterface_t * pTransport ,
79
- HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
80
- HTTPRequestHeaders_t * pRequestHeaders ,
81
- size_t reqBodyLen ,
82
- uint32_t sendFlags );
47
+ HTTPStatus_t HTTPClient_SendHttpData ( const TransportInterface_t * pTransport ,
48
+ HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
49
+ const uint8_t * pData ,
50
+ size_t dataLen );
51
+
52
+
53
+ HTTPStatus_t HTTPClient_SendHttpHeaders ( const TransportInterface_t * pTransport ,
54
+ HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
55
+ HTTPRequestHeaders_t * pRequestHeaders ,
56
+ size_t reqBodyLen ,
57
+ uint32_t sendFlags );
83
58
84
59
/**
85
60
* @brief Adds the Content-Length header field and value to the
@@ -187,20 +162,10 @@ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState,
187
162
size_t totalReceived ,
188
163
size_t responseBufferLen );
189
164
190
- /**
191
- * @brief Receive the HTTP response from the network and parse it.
192
- *
193
- * @param[in] pTransport Transport interface.
194
- * @param[in] pResponse Response message to receive data from the network.
195
- * @param[in] pRequestHeaders Request headers for the corresponding HTTP request.
196
- *
197
- * @return Returns #HTTPSuccess if successful. #HTTPNetworkError for a transport
198
- * receive error. Please see #parseHttpResponse and #getFinalResponseStatus for
199
- * other statuses returned.
200
- */
201
- static HTTPStatus_t receiveAndParseHttpResponse ( const TransportInterface_t * pTransport ,
202
- HTTPResponse_t * pResponse ,
203
- const HTTPRequestHeaders_t * pRequestHeaders );
165
+
166
+ HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse ( const TransportInterface_t * pTransport ,
167
+ HTTPResponse_t * pResponse ,
168
+ const HTTPRequestHeaders_t * pRequestHeaders );
204
169
205
170
/**
206
171
* @brief Send the HTTP request over the network.
@@ -212,7 +177,7 @@ static HTTPStatus_t receiveAndParseHttpResponse( const TransportInterface_t * pT
212
177
* @param[in] reqBodyBufLen Length of the request body buffer.
213
178
* @param[in] sendFlags Application provided flags to #HTTPClient_Send.
214
179
*
215
- * @return Returns #HTTPSuccess if successful. Please see #sendHttpHeaders and
180
+ * @return Returns #HTTPSuccess if successful. Please see #HTTPClient_SendHttpHeaders and
216
181
* #sendHttpBody for other statuses returned.
217
182
*/
218
183
static HTTPStatus_t sendHttpRequest ( const TransportInterface_t * pTransport ,
@@ -833,6 +798,9 @@ static int httpParserOnHeadersCompleteCallback( llhttp_t * pHttpParser )
833
798
assert ( pResponse != NULL );
834
799
assert ( pParsingContext -> pBufferCur != NULL );
835
800
801
+ /* Flag indicating that the headers have been completely signed - useful for libraries built on top of corehttp. */
802
+ pResponse -> areHeadersComplete = 1 ;
803
+
836
804
/* The current location to parse was updated in previous callbacks and MUST
837
805
* always be within the response buffer. */
838
806
assert ( pParsingContext -> pBufferCur >= ( const char * ) ( pResponse -> pBuffer ) );
@@ -1796,10 +1764,10 @@ HTTPStatus_t HTTPClient_AddRangeHeader( HTTPRequestHeaders_t * pRequestHeaders,
1796
1764
1797
1765
/*-----------------------------------------------------------*/
1798
1766
1799
- static HTTPStatus_t sendHttpData ( const TransportInterface_t * pTransport ,
1800
- HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
1801
- const uint8_t * pData ,
1802
- size_t dataLen )
1767
+ HTTPStatus_t HTTPClient_SendHttpData ( const TransportInterface_t * pTransport ,
1768
+ HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
1769
+ const uint8_t * pData ,
1770
+ size_t dataLen )
1803
1771
{
1804
1772
HTTPStatus_t returnStatus = HTTPSuccess ;
1805
1773
const uint8_t * pIndex = pData ;
@@ -1908,11 +1876,11 @@ static HTTPStatus_t addContentLengthHeader( HTTPRequestHeaders_t * pRequestHeade
1908
1876
1909
1877
/*-----------------------------------------------------------*/
1910
1878
1911
- static HTTPStatus_t sendHttpHeaders ( const TransportInterface_t * pTransport ,
1912
- HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
1913
- HTTPRequestHeaders_t * pRequestHeaders ,
1914
- size_t reqBodyLen ,
1915
- uint32_t sendFlags )
1879
+ HTTPStatus_t HTTPClient_SendHttpHeaders ( const TransportInterface_t * pTransport ,
1880
+ HTTPClient_GetCurrentTimeFunc_t getTimestampMs ,
1881
+ HTTPRequestHeaders_t * pRequestHeaders ,
1882
+ size_t reqBodyLen ,
1883
+ uint32_t sendFlags )
1916
1884
{
1917
1885
HTTPStatus_t returnStatus = HTTPSuccess ;
1918
1886
uint8_t shouldSendContentLength = 0U ;
@@ -1935,10 +1903,10 @@ static HTTPStatus_t sendHttpHeaders( const TransportInterface_t * pTransport,
1935
1903
{
1936
1904
LogDebug ( ( "Sending HTTP request headers: HeaderBytes=%lu" ,
1937
1905
( unsigned long ) ( pRequestHeaders -> headersLen ) ) );
1938
- returnStatus = sendHttpData ( pTransport ,
1939
- getTimestampMs ,
1940
- pRequestHeaders -> pBuffer ,
1941
- pRequestHeaders -> headersLen );
1906
+ returnStatus = HTTPClient_SendHttpData ( pTransport ,
1907
+ getTimestampMs ,
1908
+ pRequestHeaders -> pBuffer ,
1909
+ pRequestHeaders -> headersLen );
1942
1910
}
1943
1911
1944
1912
return returnStatus ;
@@ -1960,7 +1928,7 @@ static HTTPStatus_t sendHttpBody( const TransportInterface_t * pTransport,
1960
1928
/* Send the request body. */
1961
1929
LogDebug ( ( "Sending the HTTP request body: BodyBytes=%lu" ,
1962
1930
( unsigned long ) reqBodyBufLen ) );
1963
- returnStatus = sendHttpData ( pTransport , getTimestampMs , pRequestBodyBuf , reqBodyBufLen );
1931
+ returnStatus = HTTPClient_SendHttpData ( pTransport , getTimestampMs , pRequestBodyBuf , reqBodyBufLen );
1964
1932
1965
1933
return returnStatus ;
1966
1934
}
@@ -2014,9 +1982,9 @@ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState,
2014
1982
2015
1983
/*-----------------------------------------------------------*/
2016
1984
2017
- static HTTPStatus_t receiveAndParseHttpResponse ( const TransportInterface_t * pTransport ,
2018
- HTTPResponse_t * pResponse ,
2019
- const HTTPRequestHeaders_t * pRequestHeaders )
1985
+ HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse ( const TransportInterface_t * pTransport ,
1986
+ HTTPResponse_t * pResponse ,
1987
+ const HTTPRequestHeaders_t * pRequestHeaders )
2020
1988
{
2021
1989
HTTPStatus_t returnStatus = HTTPSuccess ;
2022
1990
size_t totalReceived = 0U ;
@@ -2149,11 +2117,11 @@ static HTTPStatus_t sendHttpRequest( const TransportInterface_t * pTransport,
2149
2117
assert ( getTimestampMs != NULL );
2150
2118
2151
2119
/* Send the headers, which are at one location in memory. */
2152
- returnStatus = sendHttpHeaders ( pTransport ,
2153
- getTimestampMs ,
2154
- pRequestHeaders ,
2155
- reqBodyBufLen ,
2156
- sendFlags );
2120
+ returnStatus = HTTPClient_SendHttpHeaders ( pTransport ,
2121
+ getTimestampMs ,
2122
+ pRequestHeaders ,
2123
+ reqBodyBufLen ,
2124
+ sendFlags );
2157
2125
2158
2126
/* Send the body, which is at another location in memory. */
2159
2127
if ( returnStatus == HTTPSuccess )
@@ -2269,9 +2237,9 @@ HTTPStatus_t HTTPClient_Send( const TransportInterface_t * pTransport,
2269
2237
2270
2238
if ( returnStatus == HTTPSuccess )
2271
2239
{
2272
- returnStatus = receiveAndParseHttpResponse ( pTransport ,
2273
- pResponse ,
2274
- pRequestHeaders );
2240
+ returnStatus = HTTPClient_ReceiveAndParseHttpResponse ( pTransport ,
2241
+ pResponse ,
2242
+ pRequestHeaders );
2275
2243
}
2276
2244
2277
2245
return returnStatus ;
0 commit comments