From: Dmitry Stogov Date: Thu, 20 Jan 2005 14:29:19 +0000 (+0000) Subject: Fixed bug #30901 (can't send cookies with soap envelop). X-Git-Tag: RELEASE_0_2~220 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c35353ea204654bde37991dee82a34d2d2bd339e;p=php Fixed bug #30901 (can't send cookies with soap envelop). void SoapClient::__setCookie(string name [, string value]) --- diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index b2acca55bf..47099736d0 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -471,10 +471,10 @@ try_again: if (zend_hash_index_find(Z_ARRVAL_PP(data), 0, (void**)&value) == SUCCESS && Z_TYPE_PP(value) == IS_STRING) { zval **tmp; - if (zend_hash_index_find(Z_ARRVAL_PP(data), 1, (void**)&tmp) == SUCCESS && - strncmp(phpurl->path?phpurl->path:"/",Z_STRVAL_PP(tmp),Z_STRLEN_PP(tmp)) == 0 && - zend_hash_index_find(Z_ARRVAL_PP(data), 2, (void**)&tmp) == SUCCESS && - in_domain(phpurl->host,Z_STRVAL_PP(tmp)) && + if ((zend_hash_index_find(Z_ARRVAL_PP(data), 1, (void**)&tmp) == FAILURE || + strncmp(phpurl->path?phpurl->path:"/",Z_STRVAL_PP(tmp),Z_STRLEN_PP(tmp)) == 0) && + (zend_hash_index_find(Z_ARRVAL_PP(data), 2, (void**)&tmp) == FAILURE || + in_domain(phpurl->host,Z_STRVAL_PP(tmp))) && (use_ssl || zend_hash_index_find(Z_ARRVAL_PP(data), 3, (void**)&tmp) == FAILURE)) { smart_str_appendl(&soap_headers, key, strlen(key)); smart_str_appendc(&soap_headers, '='); diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 063ed886ae..e9a0d1278d 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -235,6 +235,7 @@ PHP_METHOD(SoapClient, __getLastResponseHeaders); PHP_METHOD(SoapClient, __getFunctions); PHP_METHOD(SoapClient, __getTypes); PHP_METHOD(SoapClient, __doRequest); +PHP_METHOD(SoapClient, __setCookie); /* SoapVar Functions */ PHP_METHOD(SoapVar, SoapVar); @@ -321,6 +322,7 @@ static zend_function_entry soap_client_functions[] = { PHP_ME(SoapClient, __getFunctions, NULL, 0) PHP_ME(SoapClient, __getTypes, NULL, 0) PHP_ME(SoapClient, __doRequest, NULL, 0) + PHP_ME(SoapClient, __setCookie, NULL, 0) {NULL, NULL, NULL} }; @@ -2546,6 +2548,45 @@ PHP_METHOD(SoapClient, __doRequest) } /* }}} */ +/* {{{ proto void SoapClient::__setCookie(string name [, strung value]) + Sets cookie thet will sent with SOAP request. + The call to this function will effect all folowing calls of SOAP methods. + If value is not specified cookie is removed. */ +PHP_METHOD(SoapClient, __setCookie) +{ + char *name; + char *val = NULL; + int name_len, val_len; + zval **cookies; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", + &name, &name_len, &val, &val_len) == FAILURE) { + RETURN_NULL(); + } + + if (val == NULL) { + if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) { + zend_hash_del(Z_ARRVAL_PP(cookies), name, name_len+1); + } + } else { + zval *zcookie; + + if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) { + zval *tmp_cookies; + + MAKE_STD_ZVAL(tmp_cookies); + array_init(tmp_cookies); + zend_hash_update(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), &tmp_cookies, sizeof(zval *), (void **)&cookies); + } + + ALLOC_INIT_ZVAL(zcookie); + array_init(zcookie); + add_index_stringl(zcookie, 0, val, val_len, 1); + add_assoc_zval_ex(*cookies, name, name_len+1, zcookie); + } +} +/* }}} */ + #ifndef ZEND_ENGINE_2 static void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference) {