Skip to content

HTTP/2 + CURLOPT_FAILONERROR returns incorrect error code CURLE_RECV_ERROR #13411

Description

@laramiel

I did this

Created an http/2 request to a missing URL (404) with the following options:

curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, true)

See expected outcome.

CURLE_HTTP_RETURNED_ERROR is returned in ~2 places in http.c, which participates in this call
stack when processed via curl_easy_perform:

in http2.c, on_frame_recv, the error code lost via a conversion to NGHTTP2_ERR_CALLBACK_FAILURE

This propagates out to h2_process_pending_input which then emits CURLE_RECV_ERROR

The relevant call stack is:

http_on_response (curl/src/lib/http.c:3531)   <--- return CURLE_HTTP_RETURNED_ERROR
http_rw_headers (curl/src/lib/http.c:3779)
Curl_http_write_resp_hds (curl/src/lib/http.c:3963)
Curl_http_write_resp (curl/src/lib/http.c:3990)
Curl_xfer_write_resp (curl/src/lib/transfer.c:1166)
recvbuf_write_hds (curl/src/lib/http2.c:953)
on_stream_frame (curl/src/lib/http2.c:1011)
on_frame_recv (curl/src/lib/http2.c:1221)   <--- return NGHTTP2_ERR_CALLBACK_FAILURE
session_call_on_frame_received (nghttp2/src/lib/nghttp2_session.c:3651)
session_after_header_block_received (nghttp2/src/lib/nghttp2_session.c:4173)
nghttp2_session_mem_recv2 (nghttp2/src/lib/nghttp2_session.c:6828)
nghttp2_session_mem_recv (nghttp2/src/lib/nghttp2_session.c:5859)
h2_process_pending_input (curl/src/lib/http2.c:539)   <--- return CURLE_RECV_ERROR
h2_progress_ingress (curl/src/lib/http2.c:1872)
cf_h2_recv (curl/src/lib/http2.c:1911)
Curl_cf_def_recv (curl/src/lib/cfilters.c:103)
Curl_cf_recv (curl/src/lib/cfilters.c:184)
Curl_conn_recv (curl/src/lib/cfilters.c:688)
Curl_xfer_recv (curl/src/lib/transfer.c:1246)
Curl_xfer_recv_resp (curl/src/lib/transfer.c:197)
readwrite_data (curl/src/lib/transfer.c:253)
Curl_readwrite (curl/src/lib/transfer.c:460)
multi_runsingle (curl/src/lib/multi.c:2407)
curl_multi_perform (curl/src/lib/multi.c:2704)
easy_transfer (curl/src/lib/easy.c:676)
easy_perform (curl/src/lib/easy.c:768)
curl_easy_perform (curl/src/lib/easy.c:787)

I expected the following

https://curl.se/libcurl/c/CURLOPT_FAILONERROR.html

Actual error code CURLE_RECV_ERROR

Expected the error code CURLE_HTTP_RETURNED_ERROR

curl/libcurl version

curl 8.7.1+

operating system

Debian 6.6.13-1rodete3 (2024-03-04) x86_64 GNU/Linux

Built from source.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions