if (Z_STRLEN_P(ctype)) {
zval **headers, *opts = GET_PROP(obj, options);
- if ((SUCCESS == zend_hash_find(Z_ARRVAL_P(opts), "headers", sizeof("headers"), (void **) &headers)) && (Z_TYPE_PP(headers) == IS_ARRAY)) {
+ if ( (Z_TYPE_P(opts) == IS_ARRAY) &&
+ (SUCCESS == zend_hash_find(Z_ARRVAL_P(opts), "headers", sizeof("headers"), (void **) &headers)) &&
+ (Z_TYPE_PP(headers) == IS_ARRAY)) {
zval **ct_header;
/* only override if not already set */
MAKE_STD_ZVAL(headers);
array_init(headers);
add_assoc_stringl(headers, "Content-Type", Z_STRVAL_P(ctype), Z_STRLEN_P(ctype), 1);
- add_assoc_zval(opts, "headers", headers);
+ zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addheaders", NULL, headers);
+ zval_ptr_dtor(&headers);
}
}
--- /dev/null
+--TEST--
+HttpRequest XMLRPC
+--SKIPIF--
+<?php
+include 'skip.inc';
+checkext('xmlrpc');
+checkcls('HttpRequest');
+?>
+--FILE--
+<?php
+echo "-TEST\n";
+
+$r = new HttpRequest('http://dev.iworks.at/.print_request.php', HTTP_METH_POST);
+$r->setContentType('text/xml');
+$r->setRawPostData(xmlrpc_encode_request('testMethod', array('foo' => 'bar')));
+var_dump($r->send());
+var_dump($r->send());
+var_dump($r->send());
+
+echo "Done\n";
+?>
+--EXPECTF--
+%sTEST
+object(HttpMessage)#%d (%d) {
+ ["type:protected"]=>
+ int(2)
+ ["httpVersion:protected"]=>
+ float(1.1)
+ ["responseCode:protected"]=>
+ int(200)
+ ["responseStatus:protected"]=>
+ string(2) "OK"
+ ["requestMethod:protected"]=>
+ string(0) ""
+ ["requestUri:protected"]=>
+ string(0) ""
+ ["headers:protected"]=>
+ array(6) {
+ %s
+ }
+ ["body:protected"]=>
+ string(310) "string(294) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>testMethod</methodName>
+<params>
+ <param>
+ <value>
+ <struct>
+ <member>
+ <name>foo</name>
+ <value>
+ <string>bar</string>
+ </value>
+ </member>
+ </struct>
+ </value>
+ </param>
+</params>
+</methodCall>
+"
+
+"
+}
+object(HttpMessage)#%d (%d) {
+ ["type:protected"]=>
+ int(2)
+ ["httpVersion:protected"]=>
+ float(1.1)
+ ["responseCode:protected"]=>
+ int(200)
+ ["responseStatus:protected"]=>
+ string(2) "OK"
+ ["requestMethod:protected"]=>
+ string(0) ""
+ ["requestUri:protected"]=>
+ string(0) ""
+ ["headers:protected"]=>
+ array(6) {
+ %s
+ }
+ ["body:protected"]=>
+ string(310) "string(294) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>testMethod</methodName>
+<params>
+ <param>
+ <value>
+ <struct>
+ <member>
+ <name>foo</name>
+ <value>
+ <string>bar</string>
+ </value>
+ </member>
+ </struct>
+ </value>
+ </param>
+</params>
+</methodCall>
+"
+
+"
+}
+object(HttpMessage)#%d (%d) {
+ ["type:protected"]=>
+ int(2)
+ ["httpVersion:protected"]=>
+ float(1.1)
+ ["responseCode:protected"]=>
+ int(200)
+ ["responseStatus:protected"]=>
+ string(2) "OK"
+ ["requestMethod:protected"]=>
+ string(0) ""
+ ["requestUri:protected"]=>
+ string(0) ""
+ ["headers:protected"]=>
+ array(6) {
+ %s
+ }
+ ["body:protected"]=>
+ string(310) "string(294) "<?xml version="1.0" encoding="iso-8859-1"?>
+<methodCall>
+<methodName>testMethod</methodName>
+<params>
+ <param>
+ <value>
+ <struct>
+ <member>
+ <name>foo</name>
+ <value>
+ <string>bar</string>
+ </value>
+ </member>
+ </struct>
+ </value>
+ </param>
+</params>
+</methodCall>
+"
+
+"
+}
+Done