com php-src: http_fopen_wrapper.c - bug#732 97 Skip past "100 Continue" responses : ext/standard/http_fopen_wrapper.c

From: Date: Thu, 17 Nov 2016 10:51:53 +0000
Subject: com php-src: http_fopen_wrapper.c - bug#732 97 Skip past "100 Continue" responses : ext/standard/http_fopen_wrapper.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95838@lists.php.net to get a copy of this message
Commit: 94374c51e71854895f941ab4ea3933a91a89cdd9 Author: Rowan Collins <rowan.collins@gmail.com> Sun, 23 Oct 2016 18:24:58 +0000 Committer: Julien Pauli <jpauli@php.net> Thu, 17 Nov 2016 11:51:53 +0100 Parents: 4683377dfa6a81e632940abd92b0cbee330f89f5 Branches: PHP-7.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=94374c51e71854895f941ab4ea3933a91a89cdd9 Log: http_fopen_wrapper.c - bug#73297 Skip past "100 Continue" responses Bugs: https://bugs.php.net/73297 Changed paths: M ext/standard/http_fopen_wrapper.c Diff: diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 02b580f..72fa189 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -697,6 +697,24 @@ finish: if ((options & STREAM_ONLY_GET_HEADERS) || ignore_errors) { reqok = 1; } + + /* status codes of 1xx are "informational", and will be followed by a real response + * e.g "100 Continue". RFC 7231 states that unexpected 1xx status MUST be parsed, + * and MAY be ignored. As such, we need to skip ahead to the "real" status*/ + if (response_code >= 100 && response_code < 200) { + /* consume lines until we find a line starting 'HTTP/1' */ + while ( + !php_stream_eof(stream) + && php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL + && ( tmp_line_len < 6 || strncasecmp(tmp_line, "HTTP/1", 6) ) + ); + + if (tmp_line_len > 9) { + response_code = atoi(tmp_line + 9); + } else { + response_code = 0; + } + } /* all status codes in the 2xx range are defined by the specification as successful; * all status codes in the 3xx range are for redirection, and so also should never * fail */

« previous php.cvs (#95838) next »