[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard http_fopen_wrapper.c

2003-03-04 Thread Ilia Alshanetsky
iliaa   Tue Mar  4 11:20:52 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php4/ext/standard  http_fopen_wrapper.c 
  Log:
  MFH
  
  
Index: php4/ext/standard/http_fopen_wrapper.c
diff -u php4/ext/standard/http_fopen_wrapper.c:1.53.2.7 
php4/ext/standard/http_fopen_wrapper.c:1.53.2.8
--- php4/ext/standard/http_fopen_wrapper.c:1.53.2.7 Tue Feb 18 19:49:38 2003
+++ php4/ext/standard/http_fopen_wrapper.c  Tue Mar  4 11:20:51 2003
@@ -18,7 +18,7 @@
|  Wez Furlong [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: http_fopen_wrapper.c,v 1.53.2.7 2003/02/19 00:49:38 iliaa Exp $ */ 
+/* $Id: http_fopen_wrapper.c,v 1.53.2.8 2003/03/04 16:20:51 iliaa Exp $ */ 
 
 #include php.h
 #include php_globals.h
@@ -82,8 +82,10 @@
 #include php_fopen_wrappers.h
 
 #define HTTP_HEADER_BLOCK_SIZE 1024
+#define PHP_URL_REDIRECT_MAX   20
 
-php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, char 
*mode, int options, char **opened_path, php_stream_context *context STREAMS_DC 
TSRMLS_DC)
+
+php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, char 
*mode, int options, char **opened_path, php_stream_context *context, int redirect_max 
STREAMS_DC TSRMLS_DC)
 {
php_stream *stream = NULL;
php_url *resource = NULL;
@@ -102,14 +104,25 @@
size_t chunk_size = 0, file_size = 0;
int eol_detect;
 
-   if (strchr(mode, 'a') || strchr(mode, '+') || strchr(mode, 'w')) {
+   if (redirect_max  1) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Circular redirect, 
aborting.);
+   return NULL;
+   }
+
+   if (strpbrk(mode, aw+)) {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, HTTP wrapper 
does not support writeable connections.);
return NULL;
}
 
resource = php_url_parse(path);
-   if (resource == NULL)
+   if (resource == NULL) {
return NULL;
+   }
+
+   if (strncasecmp(resource-scheme, http, sizeof(http))  
strncasecmp(resource-scheme, https, sizeof(https))) {
+   php_url_free(resource);
+   return php_stream_open_wrapper_ex(path, mode, ENFORCE_SAFE_MODE | 
REPORT_ERRORS, NULL, context);
+   }

use_ssl = resource-scheme  (strlen(resource-scheme)  4)  
resource-scheme[4] == 's';
 
@@ -350,7 +363,11 @@
char loc_path[HTTP_HEADER_BLOCK_SIZE];
 
*new_path='\0';
-   if (strlen(location)8 || (strncasecmp(location, http://;, 
sizeof(http://;)-1)  strncasecmp(location, https://;, sizeof(https://;)-1))) {
+   if (strlen(location)8 || (strncasecmp(location, http://;, 
sizeof(http://;)-1)  
+   strncasecmp(location, 
https://;, sizeof(https://;)-1)  
+   strncasecmp(location, 
ftp://;, sizeof(ftp://;)-1)  
+   strncasecmp(location, 
ftps://, sizeof(ftps://)-1))) 
+   {
if (*location != '/') {
if (*(location+1) != '\0'  resource-path) { 
 
char *s = strrchr(resource-path, '/');
@@ -378,7 +395,7 @@
} else {
strlcpy(new_path, location, sizeof(new_path));
}
-   stream = php_stream_url_wrap_http(NULL, new_path, mode, 
options, opened_path, context STREAMS_CC TSRMLS_CC);
+   stream = php_stream_url_wrap_http_ex(NULL, new_path, mode, 
options, opened_path, context, --redirect_max STREAMS_CC TSRMLS_CC);
if (stream  stream-wrapperdata)  {
entryp = entry;
MAKE_STD_ZVAL(entry);
@@ -434,6 +451,11 @@
}

return stream;
+}
+
+php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, char 
*mode, int options, char **opened_path, php_stream_context *context STREAMS_DC 
TSRMLS_DC)
+{
+   return php_stream_url_wrap_http_ex(wrapper, path, mode, options, opened_path, 
context, PHP_URL_REDIRECT_MAX STREAMS_CC TSRMLS_CC);
 }
 
 static int php_stream_http_stream_stat(php_stream_wrapper *wrapper,



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard http_fopen_wrapper.c

2003-02-13 Thread Wez Furlong
wez Thu Feb 13 08:42:32 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php4/ext/standard  http_fopen_wrapper.c 
  Log:
  partial MFH: avoid problems with auto_detect_line_endings.
  
  
Index: php4/ext/standard/http_fopen_wrapper.c
diff -u php4/ext/standard/http_fopen_wrapper.c:1.53.2.5 
php4/ext/standard/http_fopen_wrapper.c:1.53.2.6
--- php4/ext/standard/http_fopen_wrapper.c:1.53.2.5 Wed Feb 12 19:42:06 2003
+++ php4/ext/standard/http_fopen_wrapper.c  Thu Feb 13 08:42:31 2003
@@ -18,7 +18,7 @@
|  Wez Furlong [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: http_fopen_wrapper.c,v 1.53.2.5 2003/02/13 00:42:06 pollita Exp $ */ 
+/* $Id: http_fopen_wrapper.c,v 1.53.2.6 2003/02/13 13:42:31 wez Exp $ */ 
 
 #include php.h
 #include php_globals.h
@@ -100,6 +100,7 @@
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.);
@@ -127,6 +128,11 @@
   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);
+   stream-flags = ~(PHP_STREAM_FLAG_DETECT_EOL | PHP_STREAM_FLAG_EOL_MAC);

php_stream_context_set(stream, context);
 
@@ -405,6 +411,10 @@
/* Restore original chunk size now that we're done with headers (if 
applicable) */
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;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard http_fopen_wrapper.c

2003-02-12 Thread Sara Golemon
pollita Wed Feb 12 19:42:06 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php4/ext/standard  http_fopen_wrapper.c 
  Log:
  Reverting earlier patch to reintroduce buggy behavior (yes, you heard that right) of 
filtered http streams in favor of
  performance.  This has little consequence given limited filter support in 4.3 
branch.  Filters will be redesigned in
  5.0 release. For more information see Wez, Ilia, or myself.
  
  
Index: php4/ext/standard/http_fopen_wrapper.c
diff -u php4/ext/standard/http_fopen_wrapper.c:1.53.2.4 
php4/ext/standard/http_fopen_wrapper.c:1.53.2.5
--- php4/ext/standard/http_fopen_wrapper.c:1.53.2.4 Fri Feb  7 20:36:52 2003
+++ php4/ext/standard/http_fopen_wrapper.c  Wed Feb 12 19:42:06 2003
@@ -18,7 +18,7 @@
|  Wez Furlong [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: http_fopen_wrapper.c,v 1.53.2.4 2003/02/08 01:36:52 pollita Exp $ */ 
+/* $Id: http_fopen_wrapper.c,v 1.53.2.5 2003/02/13 00:42:06 pollita Exp $ */ 
 
 #include php.h
 #include php_globals.h
@@ -122,8 +122,11 @@
if (stream == NULL) 
goto out;
 
-   /* avoid buffering issues while reading header */
-   chunk_size = php_stream_set_chunk_size(stream, 1);
+   /* 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);

php_stream_context_set(stream, context);
 
@@ -399,8 +402,9 @@
if (stream) {
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);
+   /* Restore original chunk size now that we're done with headers (if 
+applicable) */
+   if (options  STREAM_WILL_CAST)
+   php_stream_set_chunk_size(stream, chunk_size);
/* as far as streams are concerned, we are now at the start of
 * the stream */
stream-position = 0;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4(PHP_4_3) /ext/standard http_fopen_wrapper.c

2003-02-07 Thread Sara Golemon
pollita Fri Feb  7 20:36:52 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php4/ext/standard  http_fopen_wrapper.c 
  Log:
  MFH(r-1.59)
  
  
Index: php4/ext/standard/http_fopen_wrapper.c
diff -u php4/ext/standard/http_fopen_wrapper.c:1.53.2.3 
php4/ext/standard/http_fopen_wrapper.c:1.53.2.4
--- php4/ext/standard/http_fopen_wrapper.c:1.53.2.3 Fri Jan  3 12:19:46 2003
+++ php4/ext/standard/http_fopen_wrapper.c  Fri Feb  7 20:36:52 2003
@@ -18,7 +18,7 @@
|  Wez Furlong [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: http_fopen_wrapper.c,v 1.53.2.3 2003/01/03 17:19:46 iliaa Exp $ */ 
+/* $Id: http_fopen_wrapper.c,v 1.53.2.4 2003/02/08 01:36:52 pollita Exp $ */ 
 
 #include php.h
 #include php_globals.h
@@ -123,8 +123,7 @@
goto out;
 
/* avoid buffering issues while reading header */
-   if (options  STREAM_WILL_CAST)
-   chunk_size = php_stream_set_chunk_size(stream, 1);
+   chunk_size = php_stream_set_chunk_size(stream, 1);

php_stream_context_set(stream, context);
 
@@ -400,8 +399,8 @@
if (stream) {
stream-wrapperdata = response_header;
php_stream_notify_progress_init(context, 0, file_size);
-   if (options  STREAM_WILL_CAST)
-   php_stream_set_chunk_size(stream, chunk_size);
+   /* Restore original chunk size now that we're done with headers */
+   php_stream_set_chunk_size(stream, chunk_size);
/* as far as streams are concerned, we are now at the start of
 * the stream */
stream-position = 0;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php