From: Jani Taskinen Date: Sat, 1 Aug 2009 03:17:31 +0000 (+0000) Subject: - Fixed bug #43510 (stream_get_meta_data() does not return same mode as used in fopen) X-Git-Tag: php-5.4.0alpha1~191^2~2899 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbeb08f3579da63f7f7874b52fbc496021847add;p=php - Fixed bug #43510 (stream_get_meta_data() does not return same mode as used in fopen) --- diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index c36f75b4c4..840011edb6 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -369,7 +369,6 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, strlcat(scratch, " HTTP/1.0\r\n", scratch_len); } - /* send it */ php_stream_write(stream, scratch, strlen(scratch)); @@ -825,6 +824,7 @@ out: stream->wrapperdata = response_header; } php_stream_notify_progress_init(context, 0, file_size); + /* Restore original chunk size now that we're done with headers */ if (options & STREAM_WILL_CAST) php_stream_set_chunk_size(stream, chunk_size); @@ -836,6 +836,9 @@ out: * the stream */ stream->position = 0; + /* restore mode */ + strlcpy(stream->mode, mode, sizeof(stream->mode)); + if (transfer_encoding) { php_stream_filter_append(&stream->readfilters, transfer_encoding); } diff --git a/ext/standard/tests/http/bug43510.phpt b/ext/standard/tests/http/bug43510.phpt new file mode 100644 index 0000000000..5a136f3697 --- /dev/null +++ b/ext/standard/tests/http/bug43510.phpt @@ -0,0 +1,84 @@ +--TEST-- +Bug #43510: stream_get_meta_data() does not return same mode as used in fopen +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(1) "r" +string(2) "rb" +--TEST-- +Bug #43510: stream_get_meta_data() does not return same mode as used in fopen +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(1) "r" +string(2) "rb" +--TEST-- +Bug #43510: stream_get_meta_data() does not return same mode as used in fopen +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(1) "r" +string(2) "rb"