diff options
author | Daniel Stenberg <daniel@haxx.se> | 2014-10-27 16:08:24 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2014-10-27 16:28:10 +0100 |
commit | 95765567d0e9dd01a827e8defd423f27d1d03e95 (patch) | |
tree | 97fb3ddd2b9c6b9ed06e6fbf4f51f72c0fbc024f /lib | |
parent | ad88a4bbba39f5f49cddbe91e23265ee8d3cceca (diff) |
HTTP: return larger than 3 digit response codes too
HTTP 1.1 is clearly specified to only allow three digit response codes,
and libcurl used sscanf("%3d") for that purpose. This made libcurl
support smaller numbers but not larger. It does now, but we will not
make any specific promises nor document this further since it is going
outside of what HTTP is.
Bug: http://curl.haxx.se/bug/view.cgi?id=1441
Reported-by: Balaji
Diffstat (limited to 'lib')
-rw-r--r-- | lib/http.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/http.c b/lib/http.c index 3eebe2df1..989e09e20 100644 --- a/lib/http.c +++ b/lib/http.c @@ -3200,8 +3200,15 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data, #endif /* CURL_DOES_CONVERSIONS */ if(conn->handler->protocol & PROTO_FAMILY_HTTP) { + /* + * https://tools.ietf.org/html/rfc7230#section-3.1.2 + * + * The reponse code is always a three-digit number in HTTP as the spec + * says. We try to allow any number here, but we cannot make + * guarantees on future behaviors since it isn't within the protocol. + */ nc = sscanf(HEADER1, - " HTTP/%d.%d %3d", + " HTTP/%d.%d %d", &httpversion_major, &conn->httpversion, &k->httpcode); |