Skip to content

Commit

Permalink
Add http proxy support via context option.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgolemon committed Dec 3, 2003
1 parent 2065802 commit 5ad67a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion ext/standard/http_fopen_wrapper.c
Expand Up @@ -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,
Expand Down

0 comments on commit 5ad67a9

Please sign in to comment.