summaryrefslogtreecommitdiff
path: root/ext/soap/php_http.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2005-07-08 09:36:28 +0000
committerDmitry Stogov <dmitry@php.net>2005-07-08 09:36:28 +0000
commit76a447c900c2fb81ac7fc6fe7fa4b433a9d7994b (patch)
tree459963c210f48400b5c335e020e00b2037f0d7f1 /ext/soap/php_http.c
parenta7e85b3c07e7f842c84674be73fa56470d728970 (diff)
downloadphp-git-76a447c900c2fb81ac7fc6fe7fa4b433a9d7994b.tar.gz
Fixed HTTP basic authentication headers during subrequsts to xsd files
Diffstat (limited to 'ext/soap/php_http.c')
-rw-r--r--ext/soap/php_http.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index 1ba85d719b..000ce4408f 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -55,7 +55,7 @@ static int stream_alive(php_stream *stream TSRMLS_DC)
}
/* Proxy HTTP Authentication */
-static void proxy_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
+void proxy_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
{
zval **login, **password;
@@ -79,6 +79,32 @@ static void proxy_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_
}
}
+/* HTTP Authentication */
+void basic_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
+{
+ zval **login, **password;
+
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_login", sizeof("_login"), (void **)&login) == SUCCESS &&
+ !zend_hash_exists(Z_OBJPROP_P(this_ptr), "_digest", sizeof("_digest"))) {
+ char* buf;
+ int len;
+ smart_str auth = {0};
+
+ smart_str_appendl(&auth, Z_STRVAL_PP(login), Z_STRLEN_PP(login));
+ smart_str_appendc(&auth, ':');
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password"), (void **)&password) == SUCCESS) {
+ smart_str_appendl(&auth, Z_STRVAL_PP(password), Z_STRLEN_PP(password));
+ }
+ smart_str_0(&auth);
+ buf = php_base64_encode(auth.c, auth.len, &len);
+ smart_str_append_const(soap_headers, "Authorization: Basic ");
+ smart_str_appendl(soap_headers, buf, len);
+ smart_str_append_const(soap_headers, "\r\n");
+ efree(buf);
+ smart_str_free(&auth);
+ }
+}
+
static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, int *use_proxy TSRMLS_DC)
{
php_stream *stream;