summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2003-02-13 13:38:20 +0000
committerWez Furlong <wez@php.net>2003-02-13 13:38:20 +0000
commit1c3de808b9e06c78d1523dd12c0478fdd86dc970 (patch)
treeaab7877924e202f5a29a4b309447416b1968ba1f /ext
parentb81ea669a0700fc819acefaf1fd1915f7d2c5df6 (diff)
downloadphp-git-1c3de808b9e06c78d1523dd12c0478fdd86dc970.tar.gz
Avoid problems with chunk_size and auto_detect_line_endings.
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/http_fopen_wrapper.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index 12482895b3..b6ad96415c 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -100,6 +100,7 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
char *http_header_line = NULL;
char tmp_line[128];
size_t chunk_size = 0, file_size = 0;
+ int eol_detect;
if (strchr(mode, 'a') || strchr(mode, '+') || strchr(mode, 'w')) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP wrapper does not support writeable connections.");
@@ -123,8 +124,14 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
goto out;
/* avoid buffering issues while reading header */
- chunk_size = php_stream_set_chunk_size(stream, 1);
+ 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);
+ stream->flags &= ~(PHP_STREAM_FLAG_DETECT_EOL | PHP_STREAM_FLAG_EOL_MAC);
+
php_stream_context_set(stream, context);
php_stream_notify_info(context, PHP_STREAM_NOTIFY_CONNECT, NULL, 0);
@@ -400,7 +407,12 @@ 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 */
- php_stream_set_chunk_size(stream, chunk_size);
+ if (options & STREAM_WILL_CAST)
+ php_stream_set_chunk_size(stream, chunk_size);
+
+ /* restore the users auto-detect-line-endings setting */
+ stream->flags |= eol_detect;
+
/* as far as streams are concerned, we are now at the start of
* the stream */
stream->position = 0;