@@ -561,6 +561,25 @@ static llhttp_errno_t llhttp_execute_whole_response( llhttp_t * pParser,
561561 return HPE_OK ;
562562}
563563
564+ /* Mocked llhttp_execute callback that expects upgrade header in HTTP response. */
565+ static llhttp_errno_t llhttp_execute_paused_upgrade ( llhttp_t * pParser ,
566+ const char * pData ,
567+ size_t len ,
568+ int cmock_num_calls )
569+ {
570+ ( void ) cmock_num_calls ;
571+ llhttp_errno_t eReturn = HPE_OK ;
572+
573+ if ( httpParserExecuteCallCount == 0 )
574+ {
575+ eReturn = HPE_PAUSED_UPGRADE ;
576+ }
577+
578+ llhttp_execute_whole_response ( pParser , pData , len , 0 );
579+
580+ return eReturn ;
581+ }
582+
564583/* Mocked llhttp_execute callback that will be called the first time on the
565584 * response message up to the middle of the first header field, then the second
566585 * time on the response message from the middle of the first header field to the
@@ -1374,6 +1393,26 @@ void test_HTTPClient_Send_less_bytes_request_body( void )
13741393
13751394/*-----------------------------------------------------------*/
13761395
1396+ /* Test upgrade header in HTTP response. */
1397+ void test_HTTPClient_Send_paused_upgrade ( void )
1398+ {
1399+ HTTPStatus_t returnStatus = HTTPSuccess ;
1400+
1401+ llhttp_execute_Stub ( llhttp_execute_paused_upgrade );
1402+ llhttp_resume_after_upgrade_ExpectAnyArgs ();
1403+
1404+ returnStatus = HTTPClient_Send ( & transportInterface ,
1405+ & requestHeaders ,
1406+ NULL ,
1407+ 0 ,
1408+ & response ,
1409+ 0 );
1410+
1411+ TEST_ASSERT_EQUAL ( HTTPSuccess , returnStatus );
1412+ }
1413+
1414+ /*-----------------------------------------------------------*/
1415+
13771416/* Test when a network error is returned when receiving the response. */
13781417void test_HTTPClient_Send_network_error_response ( void )
13791418{
0 commit comments