Skip to content

Commit 92c2a4c

Browse files
tatsuhiro-tjay
authored andcommitted
http2: Add handling stream level error
Previously, when a stream was closed with other than NGHTTP2_NO_ERROR by RST_STREAM, underlying TCP connection was dropped. This is undesirable since there may be other streams multiplexed and they are very much fine. This change introduce new error code CURLE_HTTP2_STREAM, which indicates stream error that only affects the relevant stream, and connection should be kept open. The existing CURLE_HTTP2 means connection error in general. Ref: curl#659 Ref: curl#663
1 parent b2a0376 commit 92c2a4c

File tree

7 files changed

+20
-2
lines changed

7 files changed

+20
-2
lines changed

docs/libcurl/libcurl-errors.3

+2
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ available, the session will be queued. (added in 7.30.0)
251251
Failed to match the pinned key specified with \fICURLOPT_PINNEDPUBLICKEY(3)\fP.
252252
.IP "CURLE_SSL_INVALIDCERTSTATUS (91)"
253253
Status returned failure when asked with \fICURLOPT_SSL_VERIFYSTATUS(3)\fP.
254+
.IP "CURLE_HTTP2_STREAM (92)"
255+
Stream error in the HTTP/2 framing layer.
254256
.IP "CURLE_OBSOLETE*"
255257
These error codes will never be returned. They were used in an old libcurl
256258
version and are currently unused.

docs/libcurl/symbols-in-versions

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ CURLE_FTP_WRITE_ERROR 7.1 7.17.0
7575
CURLE_FUNCTION_NOT_FOUND 7.1
7676
CURLE_GOT_NOTHING 7.9.1
7777
CURLE_HTTP2 7.38.0
78+
CURLE_HTTP2_STREAM 7.49.0
7879
CURLE_HTTP_NOT_FOUND 7.1
7980
CURLE_HTTP_PORT_FAILED 7.3 7.12.0
8081
CURLE_HTTP_POST_ERROR 7.1

include/curl/curl.h

+2
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ typedef enum {
537537
CURLE_SSL_PINNEDPUBKEYNOTMATCH, /* 90 - specified pinned public key did not
538538
match */
539539
CURLE_SSL_INVALIDCERTSTATUS, /* 91 - invalid certificate status */
540+
CURLE_HTTP2_STREAM, /* 92 - stream error in HTTP/2 framing layer
541+
*/
540542
CURL_LAST /* never use! */
541543
} CURLcode;
542544

lib/http2.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
10591059
if(stream->error_code != NGHTTP2_NO_ERROR) {
10601060
failf(data, "HTTP/2 stream %u was not closed cleanly: error_code = %d",
10611061
stream->stream_id, stream->error_code);
1062-
*err = CURLE_HTTP2;
1062+
*err = CURLE_HTTP2_STREAM;
10631063
return -1;
10641064
}
10651065

@@ -1231,6 +1231,13 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
12311231
*err = CURLE_AGAIN;
12321232
return -1;
12331233
}
1234+
else if(!nghttp2_session_want_read(httpc->h2) &&
1235+
!nghttp2_session_want_write(httpc->h2)) {
1236+
DEBUGF(infof(data,
1237+
"http2_recv: nothing to do in this session\n"));
1238+
*err = CURLE_HTTP2;
1239+
return -1;
1240+
}
12341241
else {
12351242
char *inbuf;
12361243
/* remember where to store incoming data for this stream and how big the

lib/multi.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
18801880
* happened in the data connection.
18811881
*/
18821882

1883-
if(!(data->easy_conn->handler->flags & PROTOPT_DUAL))
1883+
if(!(data->easy_conn->handler->flags & PROTOPT_DUAL) &&
1884+
result != CURLE_HTTP2_STREAM)
18841885
connclose(data->easy_conn, "Transfer returned error");
18851886

18861887
Curl_posttransfer(data);

lib/strerror.c

+3
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ curl_easy_strerror(CURLcode error)
305305
case CURLE_SSL_INVALIDCERTSTATUS:
306306
return "SSL server certificate status verification FAILED";
307307

308+
case CURLE_HTTP2_STREAM:
309+
return "Stream error in the HTTP/2 framing layer";
310+
308311
/* error codes not used by current libcurl */
309312
case CURLE_OBSOLETE20:
310313
case CURLE_OBSOLETE24:

packages/OS400/curl.inc.in

+2
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@
534534
d c 90
535535
d CURLE_SSL_INVALIDCERTSTATUS...
536536
d c 91
537+
d CURLE_HTTP2_STREAM...
538+
d c 92
537539
*
538540
/if not defined(CURL_NO_OLDIES)
539541
d CURLE_URL_MALFORMAT_USER...

0 commit comments

Comments
 (0)