@@ -328,21 +328,49 @@ void sh2lib_free(struct sh2lib_handle *hd)
328328int sh2lib_execute (struct sh2lib_handle * hd )
329329{
330330 int ret ;
331- ret = nghttp2_session_send (hd -> http2_sess );
331+ ret = sh2lib_execute_send (hd );
332332 if (ret != 0 ) {
333- ESP_LOGE (TAG , "[sh2-execute] HTTP2 session send failed %d" , ret );
334333 return ret ;
335334 }
336335
337- ret = nghttp2_session_recv (hd -> http2_sess );
336+ ret = sh2lib_execute_recv (hd );
338337 if (ret != 0 ) {
339- ESP_LOGE (TAG , "[sh2-execute] HTTP2 session recv failed %d" , ret );
340338 return ret ;
341339 }
342340
343341 return 0 ;
344342}
345343
344+ int sh2lib_execute_recv (struct sh2lib_handle * hd )
345+ {
346+ if (hd == NULL ) {
347+ ESP_LOGE (TAG , "[sh2-execute-recv] pointer to sh2lib handle cannot be NULL" );
348+ return -1 ;
349+ }
350+
351+ int ret = nghttp2_session_recv (hd -> http2_sess );
352+ if (ret != 0 ) {
353+ ESP_LOGE (TAG , "[sh2-execute-recv] HTTP2 session recv failed %d" , ret );
354+ }
355+
356+ return ret ;
357+ }
358+
359+ int sh2lib_execute_send (struct sh2lib_handle * hd )
360+ {
361+ if (hd == NULL ) {
362+ ESP_LOGE (TAG , "[sh2-execute-recv] pointer to sh2lib handle cannot be NULL" );
363+ return -1 ;
364+ }
365+
366+ int ret = nghttp2_session_send (hd -> http2_sess );
367+ if (ret != 0 ) {
368+ ESP_LOGE (TAG , "[sh2-execute-send] HTTP2 session send failed %d" , ret );
369+ }
370+
371+ return ret ;
372+ }
373+
346374int sh2lib_do_get_with_nv (struct sh2lib_handle * hd , const nghttp2_nv * nva , size_t nvlen , sh2lib_frame_data_recv_cb_t recv_cb )
347375{
348376 int ret = nghttp2_submit_request (hd -> http2_sess , NULL , nva , nvlen , NULL , recv_cb );
0 commit comments