Skip to content

Commit 096aa46

Browse files
Merge branch 'main' into updateManifest
2 parents 3493a3f + da57340 commit 096aa46

3 files changed

Lines changed: 56 additions & 18 deletions

File tree

CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(coreHTTP LANGUAGES C)
4+
5+
# ------------------------------------------------------------------------------
6+
# Includes
7+
# ------------------------------------------------------------------------------
8+
9+
include(${CMAKE_CURRENT_LIST_DIR}/httpFilePaths.cmake)
10+
11+
# ------------------------------------------------------------------------------
12+
# Library targets
13+
# ------------------------------------------------------------------------------
14+
15+
add_library(core_http INTERFACE)
16+
17+
target_sources(core_http INTERFACE ${HTTP_SOURCES})
18+
19+
target_include_directories(core_http
20+
INTERFACE ${HTTP_INCLUDE_NO_INTERFACE_PUBLIC_DIRS})
21+
22+
# Separate transport interface library to prevent conflicts with coreMQTT
23+
if(NOT TARGET coremqtt_corehttp_transport_interface)
24+
add_library(coremqtt_corehttp_transport_interface INTERFACE)
25+
26+
target_include_directories(coremqtt_corehttp_transport_interface
27+
INTERFACE ${HTTP_TRANSPORT_INTERFACE_INCLUDE_DIRS})
28+
endif()
29+
30+
target_link_libraries(core_http INTERFACE coremqtt_corehttp_transport_interface)

httpFilePaths.cmake

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ set( HTTP_SOURCES
1212
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/llhttp.c
1313
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/src/http.c )
1414

15-
# HTTP library public include directories.
16-
set( HTTP_INCLUDE_PUBLIC_DIRS
15+
# HTTP library public include directories without transport interface.
16+
set( HTTP_INCLUDE_NO_INTERFACE_PUBLIC_DIRS
1717
${CMAKE_CURRENT_LIST_DIR}/source/include
18-
${CMAKE_CURRENT_LIST_DIR}/source/interface
1918
${CMAKE_CURRENT_LIST_DIR}/source/dependency/3rdparty/llhttp/include )
19+
20+
# Transport interface include directory.
21+
set( HTTP_TRANSPORT_INTERFACE_INCLUDE_DIRS
22+
${CMAKE_CURRENT_LIST_DIR}/source/interface )
23+
24+
# HTTP library public include directories.
25+
set( HTTP_INCLUDE_PUBLIC_DIRS
26+
${HTTP_INCLUDE_NO_INTERFACE_PUBLIC_DIRS}
27+
${HTTP_TRANSPORT_INTERFACE_INCLUDE_DIRS} )

source/core_http_client.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,14 +1006,14 @@ static void initializeParsingContextForFirstResponse( HTTPParsingContext_t * pPa
10061006

10071007
/* Initialize the callbacks that llhttp_execute will invoke. */
10081008
llhttp_settings_init( &( pParsingContext->llhttpSettings ) );
1009-
pParsingContext->llhttpSettings.on_message_begin = httpParserOnMessageBeginCallback;
1010-
pParsingContext->llhttpSettings.on_status = httpParserOnStatusCallback;
1011-
pParsingContext->llhttpSettings.on_status_complete = httpParserOnStatusCompleteCallback;
1012-
pParsingContext->llhttpSettings.on_header_field = httpParserOnHeaderFieldCallback;
1013-
pParsingContext->llhttpSettings.on_header_value = httpParserOnHeaderValueCallback;
1014-
pParsingContext->llhttpSettings.on_headers_complete = httpParserOnHeadersCompleteCallback;
1015-
pParsingContext->llhttpSettings.on_body = httpParserOnBodyCallback;
1016-
pParsingContext->llhttpSettings.on_message_complete = httpParserOnMessageCompleteCallback;
1009+
pParsingContext->llhttpSettings.on_message_begin = &httpParserOnMessageBeginCallback;
1010+
pParsingContext->llhttpSettings.on_status = &httpParserOnStatusCallback;
1011+
pParsingContext->llhttpSettings.on_status_complete = &httpParserOnStatusCompleteCallback;
1012+
pParsingContext->llhttpSettings.on_header_field = &httpParserOnHeaderFieldCallback;
1013+
pParsingContext->llhttpSettings.on_header_value = &httpParserOnHeaderValueCallback;
1014+
pParsingContext->llhttpSettings.on_headers_complete = &httpParserOnHeadersCompleteCallback;
1015+
pParsingContext->llhttpSettings.on_body = &httpParserOnBodyCallback;
1016+
pParsingContext->llhttpSettings.on_message_complete = &httpParserOnMessageCompleteCallback;
10171017

10181018
/* Initialize the third-party HTTP parser to parse responses. */
10191019
llhttp_init( &( pParsingContext->llhttpParser ), HTTP_RESPONSE, &( pParsingContext->llhttpSettings ) );
@@ -1829,7 +1829,7 @@ HTTPStatus_t HTTPClient_SendHttpData( const TransportInterface_t * pTransport,
18291829

18301830
/* If the timestamp function was undefined by the application, then do not
18311831
* retry the transport send. */
1832-
if( getTimestampMs == getZeroTimestampMs )
1832+
if( getTimestampMs == &getZeroTimestampMs )
18331833
{
18341834
retryTimeoutMs = 0U;
18351835
}
@@ -2004,7 +2004,7 @@ static HTTPStatus_t getFinalResponseStatus( HTTPParsingState_t parsingState,
20042004
{
20052005
/* HTTP_PARSING_INCOMPLETE is okay when HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG is set
20062006
* as the body data may yet to be read from the transport. */
2007-
if( ( pResponse->respOptionFlags & HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG ) == 0 )
2007+
if( ( pResponse->respOptionFlags & HTTP_RESPONSE_DO_NOT_PARSE_BODY_FLAG ) == 0U )
20082008
{
20092009
if( totalReceived == pResponse->bufferLen )
20102010
{
@@ -2057,7 +2057,7 @@ HTTPStatus_t HTTPClient_ReceiveAndParseHttpResponse( const TransportInterface_t
20572057

20582058
/* If the timestamp function was undefined by the application, then do not
20592059
* retry the transport receive. */
2060-
if( pResponse->getTime == getZeroTimestampMs )
2060+
if( pResponse->getTime == &getZeroTimestampMs )
20612061
{
20622062
retryTimeoutMs = 0U;
20632063
}
@@ -2286,7 +2286,7 @@ HTTPStatus_t HTTPClient_Send( const TransportInterface_t * pTransport,
22862286
{
22872287
/* Set a zero timestamp function when the application did not configure
22882288
* one. */
2289-
pResponse->getTime = getZeroTimestampMs;
2289+
pResponse->getTime = &getZeroTimestampMs;
22902290
}
22912291

22922292
returnStatus = HTTPSuccess;
@@ -2471,9 +2471,9 @@ static HTTPStatus_t findHeaderInResponse( const uint8_t * pBuffer,
24712471
* need to create a private context in llhttp->data that has the field and
24722472
* value to update and pass back. */
24732473
llhttp_settings_init( &parserSettings );
2474-
parserSettings.on_header_field = findHeaderFieldParserCallback;
2475-
parserSettings.on_header_value = findHeaderValueParserCallback;
2476-
parserSettings.on_headers_complete = findHeaderOnHeaderCompleteCallback;
2474+
parserSettings.on_header_field = &findHeaderFieldParserCallback;
2475+
parserSettings.on_header_value = &findHeaderValueParserCallback;
2476+
parserSettings.on_headers_complete = &findHeaderOnHeaderCompleteCallback;
24772477
llhttp_init( &parser, HTTP_RESPONSE, &parserSettings );
24782478

24792479
/* Set the context for the parser. */

0 commit comments

Comments
 (0)