fix: Fix error handling of return values
issue
@@ -301,6 +301,7 @@ BOAT_RESULT http2SubmitRequest(http2IntfContext *context)
// char *pathTmp = NULL;
// Http2Response *parsePtr = NULL;
BOAT_RESULT result = BOAT_SUCCESS;
+ BSINT32 nghttp2_result = 0;
boat_try_declare;
nghttp2_nv nva[] = {MAKE_NV(":method", "POST"),
MAKE_NV(":scheme", "http"),
@@ -350,27 +351,27 @@ BOAT_RESULT http2SubmitRequest(http2IntfContext *context)
nghttp2_session_client_new(&context->session, callbacks, context);
nghttp2_session_callbacks_del(callbacks);
- result = nghttp2_submit_settings(context->session, NGHTTP2_FLAG_NONE, NULL, 0);
- if (result != BOAT_SUCCESS)
+ nghttp2_result = nghttp2_submit_settings(context->session, NGHTTP2_FLAG_NONE, NULL, 0);
+ if (nghttp2_result < 0)
{
BoatLog(BOAT_LOG_CRITICAL, "submit settings failed.");
boat_throw(BOAT_ERROR_HTTP2_INTERNAL + result, http2SubmitRequest_exception);
}
data_prd.read_callback = data_source_read_callback;
- result = nghttp2_submit_request(context->session, NULL, nva, sizeof(nva) / sizeof(nva[0]), &data_prd, NULL);
- if (result != BOAT_SUCCESS)
+ nghttp2_result = nghttp2_submit_request(context->session, NULL, nva, sizeof(nva) / sizeof(nva[0]), &data_prd, NULL);
+ if (nghttp2_result < 0)
{
BoatLog(BOAT_LOG_CRITICAL, "submit request failed.");
boat_throw(BOAT_ERROR_HTTP2_INTERNAL + result, http2SubmitRequest_exception);
}
- result = nghttp2_session_send(context->session);
- if (result != BOAT_SUCCESS)
+ nghttp2_result = nghttp2_session_send(context->session);
+ if (nghttp2_result < 0)
{
BoatLog(BOAT_LOG_CRITICAL, "submit request failed.");
boat_throw(BOAT_ERROR_HTTP2_INTERNAL + result, http2SubmitRequest_exception);
}
- result = nghttp2_session_recv(context->session);
- if (result != BOAT_SUCCESS)
+ nghttp2_result = nghttp2_session_recv(context->session);
+ if (nghttp2_result < 0)
{
BoatLog(BOAT_LOG_CRITICAL, "submit request failed.");
boat_throw(BOAT_ERROR_HTTP2_INTERNAL + result, http2SubmitRequest_exception);
