Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions sh2lib/sh2lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,49 @@ void sh2lib_free(struct sh2lib_handle *hd)
int sh2lib_execute(struct sh2lib_handle *hd)
{
int ret;
ret = nghttp2_session_send(hd->http2_sess);
ret = sh2lib_execute_send(hd);
if (ret != 0) {
ESP_LOGE(TAG, "[sh2-execute] HTTP2 session send failed %d", ret);
return ret;
}

ret = nghttp2_session_recv(hd->http2_sess);
ret = sh2lib_execute_recv(hd);
if (ret != 0) {
ESP_LOGE(TAG, "[sh2-execute] HTTP2 session recv failed %d", ret);
return ret;
}

return 0;
}

int sh2lib_execute_recv(struct sh2lib_handle *hd)
{
if (hd == NULL) {
ESP_LOGE(TAG, "[sh2-execute-recv] pointer to sh2lib handle cannot be NULL");
return -1;
}

int ret = nghttp2_session_recv(hd->http2_sess);
if (ret != 0) {
ESP_LOGE(TAG, "[sh2-execute-recv] HTTP2 session recv failed %d", ret);
}

return ret;
}

int sh2lib_execute_send(struct sh2lib_handle *hd)
{
if (hd == NULL) {
ESP_LOGE(TAG, "[sh2-execute-recv] pointer to sh2lib handle cannot be NULL");
return -1;
}

int ret = nghttp2_session_send(hd->http2_sess);
if (ret != 0) {
ESP_LOGE(TAG, "[sh2-execute-send] HTTP2 session send failed %d", ret);
}

return ret;
}

int sh2lib_do_get_with_nv(struct sh2lib_handle *hd, const nghttp2_nv *nva, size_t nvlen, sh2lib_frame_data_recv_cb_t recv_cb)
{
int ret = nghttp2_submit_request(hd->http2_sess, NULL, nva, nvlen, NULL, recv_cb);
Expand Down
32 changes: 32 additions & 0 deletions sh2lib/sh2lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,38 @@ int sh2lib_do_put(struct sh2lib_handle *hd, const char *path,
*/
int sh2lib_execute(struct sh2lib_handle *hd);

/**
* @brief Execute receive on an HTTP/2 connection
*
* While the API sh2lib_do_get(), sh2lib_do_post() setup the requests to be
* initiated with the server, this API performs the actual data send/receive
* operations on the HTTP/2 connection. The callback functions are accordingly
* called during the processing of these requests.
*
* @param[in] hd Pointer to a variable of the type 'struct sh2lib_handle'
*
* @return
* - 0 if it succeeds
* - Negative error code from nghttp2 on failure
*/
int sh2lib_execute_recv(struct sh2lib_handle *hd);

/**
* @brief Execute send on an HTTP/2 connection
*
* While the API sh2lib_do_get(), sh2lib_do_post() setup the requests to be
* initiated with the server, this API performs the actual data send/receive
* operations on the HTTP/2 connection. The callback functions are accordingly
* called during the processing of these requests.
*
* @param[in] hd Pointer to a variable of the type 'struct sh2lib_handle'
*
* @return
* - 0 if it succeeds
* - Negative error code from nghttp2 on failure
*/
int sh2lib_execute_send(struct sh2lib_handle *hd);

#define SH2LIB_MAKE_NV(NAME, VALUE) \
{ \
(uint8_t *)NAME, (uint8_t *)VALUE, strlen(NAME), strlen(VALUE), \
Expand Down
Loading