Add http proxy support via context option.

This commit is contained in:
Sara Golemon 2003-12-03 05:30:16 +00:00
parent 20658020bd
commit 5ad67a9215
2 changed files with 11 additions and 1 deletions

1
NEWS
View File

@ -8,6 +8,7 @@ PHP NEWS
- Added possibility to prevent PHP from registering variables when
input filter support is used. (Derick)
- Added EXSLT support in ext/xsl. (Christian)
- Added proxy support to http wrapper. (Sara)
- Added new functions:
. dba_key_split() to split inifile keys in an array. (Marcus)
. time_nanosleep() signal safe sleep (Magnus, Ilia)

View File

@ -134,7 +134,16 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path,
else if (resource->port == 0)
resource->port = 80;
transport_len = spprintf(&transport_string, 0, "%s://%s:%d", use_ssl ? "ssl" : "tcp", resource->host, resource->port);
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 */
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,
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,