Skip to content

Commit c930230

Browse files
committed
Fix GH-10031: [Stream] STREAM_NOTIFY_PROGRESS over HTTP emitted irregularly for last chunk of data
Fixes GH-10031 It's possible that the server already sent in more data than just the headers. Since the stream only accepts progress increments after the headers are processed, the already read data is never added to the process. We account for this by adjusting the progress counter by the difference of already read header data and the body.
1 parent d17175c commit c930230

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/standard/http_fopen_wrapper.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,13 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
955955
if (transfer_encoding) {
956956
php_stream_filter_append(&stream->readfilters, transfer_encoding);
957957
}
958+
959+
/* It's possible that the server already sent in more data than just the headers.
960+
* We account for this by adjusting the progress counter by the difference of
961+
* already read header data and the body. */
962+
if (stream->writepos > stream->readpos) {
963+
php_stream_notify_progress_increment(context, stream->writepos - stream->readpos, 0);
964+
}
958965
}
959966

960967
return stream;

0 commit comments

Comments
 (0)