From 09d0f92e051b0a1512052b30ca7d889fb8a5b0ee Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Tue, 6 May 2003 11:04:42 +0000 Subject: [PATCH] Fix URL reading --- ext/standard/http_fopen_wrapper.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 1276e0dcb5..0a4d7f5682 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -136,12 +136,6 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, if (stream == NULL) goto out; - /* Ordinarily we'd always reduce chunk_size to 1 to avoid filter problems. - However, since 4.3 filter support is extremely limited and will be completely rewritten in 5.0 - we'll accept the unexpected behavior of filtered http streams in favor of improved performance. */ - if (options & STREAM_WILL_CAST) - chunk_size = php_stream_set_chunk_size(stream, 1); - /* avoid problems with auto-detecting when reading the headers -> the headers * are always in canonical \r\n format */ eol_detect = stream->flags & (PHP_STREAM_FLAG_DETECT_EOL | PHP_STREAM_FLAG_EOL_MAC); @@ -267,6 +261,15 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, location[0] = '\0'; + /* + * We need to read the HTTP response header one-by-one, because + * the original author did not know about MSG_PEEK. + * The chunk_size will be reset later, once we have read the + * header completely. + */ + if (options & STREAM_WILL_CAST) + chunk_size = php_stream_set_chunk_size(stream, 1); + if (!header_init && FAILURE == zend_hash_find(EG(active_symbol_table), "http_response_header", sizeof("http_response_header"), (void **) &response_header)) { header_init = 1; -- 2.50.1