pollita Sat Jul 24 00:01:48 2004 EDT
Modified files:
/php-src/ext/standard ftp_fopen_wrapper.c http_fopen_wrapper.c
/php-src NEWS
Log:
Add proxy support to ftp using http wrapper
http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.75&r2=1.76&ty=u
Index: php-src/ext/standard/ftp_fopen_wrapper.c
diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.75
php-src/ext/standard/ftp_fopen_wrapper.c:1.76
--- php-src/ext/standard/ftp_fopen_wrapper.c:1.75 Wed Jul 21 00:37:47 2004
+++ php-src/ext/standard/ftp_fopen_wrapper.c Sat Jul 24 00:01:48 2004
@@ -18,7 +18,7 @@
| Sara Golemon <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: ftp_fopen_wrapper.c,v 1.75 2004/07/21 04:37:47 pollita Exp $ */
+/* $Id: ftp_fopen_wrapper.c,v 1.76 2004/07/24 04:01:48 pollita Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -384,6 +384,12 @@
int allow_overwrite = 0;
int read_write = 0;
+ if (context &&
+ php_stream_context_get_option(context, "ftp", "proxy", &tmpzval) ==
SUCCESS) {
+ /* Use http wrapper to proxy ftp request */
+ return php_stream_url_wrap_http(wrapper, path, mode, options,
opened_path, context STREAMS_CC TSRMLS_CC);
+ }
+
tmp_line[0] = '\0';
if (strpbrk(mode, "r+")) {
@@ -1130,7 +1136,7 @@
php_stream_ftp_stream_stat,
php_stream_ftp_url_stat, /* stat_url */
php_stream_ftp_opendir, /* opendir */
- "FTP",
+ "ftp",
php_stream_ftp_unlink, /* unlink */
php_stream_ftp_rename, /* rename */
php_stream_ftp_mkdir, /* mkdir */
http://cvs.php.net/diff.php/php-src/ext/standard/http_fopen_wrapper.c?r1=1.88&r2=1.89&ty=u
Index: php-src/ext/standard/http_fopen_wrapper.c
diff -u php-src/ext/standard/http_fopen_wrapper.c:1.88
php-src/ext/standard/http_fopen_wrapper.c:1.89
--- php-src/ext/standard/http_fopen_wrapper.c:1.88 Fri May 28 09:38:06 2004
+++ php-src/ext/standard/http_fopen_wrapper.c Sat Jul 24 00:01:48 2004
@@ -18,7 +18,7 @@
| Wez Furlong <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: http_fopen_wrapper.c,v 1.88 2004/05/28 13:38:06 sesser Exp $ */
+/* $Id: http_fopen_wrapper.c,v 1.89 2004/07/24 04:01:48 pollita Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -114,37 +114,50 @@
return NULL;
}
- if (strpbrk(mode, "awx+")) {
- 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) {
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';
- /* choose default ports */
- if (use_ssl && resource->port == 0)
- resource->port = 443;
- else if (resource->port == 0)
- resource->port = 80;
-
- if (context && !use_ssl &&
- php_stream_context_get_option(context, "http", "proxy", &tmpzval) ==
SUCCESS &&
- Z_TYPE_PP(tmpzval) == IS_STRING &&
- Z_STRLEN_PP(tmpzval) > 0) {
- /* Don't use proxy server for SSL resources */
+ if (!context ||
+ php_stream_context_get_option(context, wrapper->wops->label,
"proxy", &tmpzval) == FAILURE ||
+ Z_TYPE_PP(tmpzval) != IS_STRING ||
+ Z_STRLEN_PP(tmpzval) <= 0) {
+ php_url_free(resource);
+ return php_stream_open_wrapper_ex(path, mode,
ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
+ }
+ /* Called from a non-http wrapper with http proxying requested (i.e.
ftp) */
+ request_fulluri = 1;
+ use_ssl = 0;
+
transport_len = Z_STRLEN_PP(tmpzval);
transport_string = estrndup(Z_STRVAL_PP(tmpzval),
Z_STRLEN_PP(tmpzval));
} else {
- transport_len = spprintf(&transport_string, 0, "%s://%s:%d", use_ssl ?
"ssl" : "tcp", resource->host, resource->port);
+ /* Normal http request (possibly with proxy) */
+
+ if (strpbrk(mode, "awx+")) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "HTTP
wrapper does not support writeable connections.");
+ return NULL;
+ }
+
+ use_ssl = resource->scheme && (strlen(resource->scheme) > 4) &&
resource->scheme[4] == 's';
+ /* choose default ports */
+ if (use_ssl && resource->port == 0)
+ resource->port = 443;
+ else if (resource->port == 0)
+ resource->port = 80;
+
+ if (context && !use_ssl &&
+ php_stream_context_get_option(context, wrapper->wops->label,
"proxy", &tmpzval) == SUCCESS &&
+ Z_TYPE_PP(tmpzval) == IS_STRING &&
+ Z_STRLEN_PP(tmpzval) > 0) {
+ /* Don't use proxy server for SSL resources */
+ transport_len = Z_STRLEN_PP(tmpzval);
+ transport_string = estrndup(Z_STRVAL_PP(tmpzval),
Z_STRLEN_PP(tmpzval));
+ } else {
+ transport_len = spprintf(&transport_string, 0, "%s://%s:%d",
use_ssl ? "ssl" : "tcp", resource->host, resource->port);
+ }
}
stream = php_stream_xport_create(transport_string, transport_len, options,
@@ -192,7 +205,8 @@
}
/* Should we send the entire path in the request line, default to no. */
- if (context &&
+ if (!request_fulluri &&
+ context &&
php_stream_context_get_option(context, "http", "request_fulluri",
&tmpzval) == SUCCESS) {
(*tmpzval)->refcount++;
SEPARATE_ZVAL(tmpzval);
@@ -292,7 +306,8 @@
/* Send Host: header so name-based virtual hosts work */
if ((have_header & HTTP_HEADER_HOST) == 0) {
- if ((use_ssl && resource->port != 443) || (!use_ssl && resource->port
!= 80)) {
+ if ((use_ssl && resource->port != 443 && resource->port != 0) ||
+ (!use_ssl && resource->port != 80 && resource->port != 0))
{
if (snprintf(scratch, scratch_len, "Host: %s:%i\r\n",
resource->host, resource->port) > 0)
php_stream_write(stream, scratch, strlen(scratch));
} else {
@@ -525,7 +540,7 @@
} else {
strlcpy(new_path, location, sizeof(new_path));
}
- stream = php_stream_url_wrap_http_ex(NULL, new_path, mode,
options, opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC);
+ stream = php_stream_url_wrap_http_ex(wrapper, new_path, mode,
options, opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC);
if (stream && stream->wrapperdata) {
entryp = &entry;
MAKE_STD_ZVAL(entry);
@@ -594,7 +609,7 @@
php_stream_http_stream_stat,
NULL, /* stat_url */
NULL, /* opendir */
- "HTTP",
+ "http",
NULL, /* unlink */
NULL, /* rename */
NULL, /* mkdir */
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1772&r2=1.1773&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1772 php-src/NEWS:1.1773
--- php-src/NEWS:1.1772 Fri Jul 23 08:47:36 2004
+++ php-src/NEWS Sat Jul 24 00:01:48 2004
@@ -15,6 +15,7 @@
. stream_socket_enable_crypto() (Wez)
- PHP will now respect extension dependencies when initializing. (Wez)
- Added Cursor support for MySQL 5.0.x in mysqli (Georg)
+- Added proxy support to ftp wrapper via http. (Sara)
- Added MDTM support to ftp_url_stat. (Sara)
- Added zlib stream filter suport. (Sara)
- Added bz2 stream filter support. (Sara)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php