After some more testing I needed to tweak the patch and the example, here is version 2.

 $opts = array('http' => array('header' => 'X-foo: bar'));
 $ctx = stream_context_create($opts);

Brian


--- ext/soap/php_http.c.orig    2008-09-26 05:39:50.000000000 -0700
+++ ext/soap/php_http.c 2008-09-26 06:42:34.000000000 -0700
 -391,7 +391,8 @@
        PG(allow_url_fopen) = old_allow_url_fopen;

        if (stream) {
-               zval **cookies, **login, **password;
+           php_stream_context *context = NULL;
+               zval **cookies, **login, **password, **tmpzval = NULL;
          int ret = zend_list_insert(phpurl, le_url);

                add_property_resource(this_ptr, "httpurl", ret);
 -638,6 +639,19 @@
                        proxy_authentication(this_ptr, &soap_headers TSRMLS_CC);
                }

+               /* get context to check for http headers */
+               if (SUCCESS == zend_hash_find(Z_OBJPROP_P(this_ptr),
+ "_stream_context", sizeof("_stream_context"), (void**)&tmp)) {
+                   context = php_stream_context_from_zval(*tmp, 0);
+               }
+
+               /* Send http headers from context */
+               if (context &&
+ php_stream_context_get_option(context, "http", "header", &tmpzval) == SUCCESS &&
+                   Z_TYPE_PP(tmpzval) == IS_STRING && Z_STRLEN_PP(tmpzval)) {
+ smart_str_appendl(&soap_headers, Z_STRVAL_PP(tmpzval), Z_STRLEN_PP(tmpzval));
+               }
+
                /* Send cookies along with request */
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) {
                        zval **data;

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to