]> granicus.if.org Git - php/commitdiff
Fixed bug #30901 (can't send cookies with soap envelop).
authorDmitry Stogov <dmitry@php.net>
Thu, 20 Jan 2005 14:29:19 +0000 (14:29 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 20 Jan 2005 14:29:19 +0000 (14:29 +0000)
void SoapClient::__setCookie(string name [, string value])

ext/soap/php_http.c
ext/soap/soap.c

index b2acca55bfea9651fd0a5cbbe58a7aa64c10bbfb..47099736d0d062d7f0056a028dc8e013a67e887c 100644 (file)
@@ -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, '=');
index 063ed886ae12b454b3388ab0ffaf238f399c4850..e9a0d1278d5e83dc47076867d755b23ee8cbc5a1 100644 (file)
@@ -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)
 {