From: Michael Wallner Date: Fri, 23 Feb 2007 08:13:15 +0000 (+0000) Subject: - Allow unsetting request options by passing NULL: X-Git-Tag: RELEASE_1_5_2~4 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=207d60b3e6c3735999b3467377b60dab35981429;p=m6w6%2Fext-http - Allow unsetting request options by passing NULL: $request->setOptions(array("option" => NULL)); --- diff --git a/http_request_object.c b/http_request_object.c index 1b2a543..0c65812 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -888,6 +888,8 @@ PHP_METHOD(HttpRequest, setOptions) RETURN_TRUE; } + old_opts = zend_read_property(THIS_CE, getThis(), ZEND_STRS("options")-1, 0 TSRMLS_CC); + MAKE_STD_ZVAL(add_opts); array_init(add_opts); /* some options need extra attention -- thus cannot use array_merge() directly */ @@ -913,6 +915,10 @@ PHP_METHOD(HttpRequest, setOptions) http_request_enable_cookies(obj->request); } else if (!strcasecmp(key.str, "recordHistory")) { zend_update_property_bool(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, 1 TSRMLS_CC); + } else if (Z_TYPE_PP(opt) == IS_NULL) { + if (Z_TYPE_P(old_opts) == IS_ARRAY) { + zend_hash_del(Z_ARRVAL_P(old_opts), key.str, key.len); + } } else { ZVAL_ADDREF(*opt); add_assoc_zval_ex(add_opts, key.str, key.len, *opt); @@ -920,7 +926,6 @@ PHP_METHOD(HttpRequest, setOptions) } } - old_opts = zend_read_property(THIS_CE, getThis(), ZEND_STRS("options")-1, 0 TSRMLS_CC); if (Z_TYPE_P(old_opts) == IS_ARRAY) { array_copy(Z_ARRVAL_P(old_opts), Z_ARRVAL_P(new_opts)); }