- fix tests
[m6w6/ext-http] / http_request_object.c
index 1b2a543bc5dd803d4d63c87b7511174e3fc96f19..7f427b8c0eda5e3a915dfa0e6543ef42ee6da730 100644 (file)
@@ -893,26 +893,32 @@ PHP_METHOD(HttpRequest, setOptions)
        /* some options need extra attention -- thus cannot use array_merge() directly */
        FOREACH_KEYVAL(pos, opts, key, opt) {
                if (key.type == HASH_KEY_IS_STRING) {
-                       if (!strcmp(key.str, "headers")) {
+#define KEYMATCH(k, s) ((sizeof(s)==k.len) && !strcasecmp(k.str, s))
+                       if (KEYMATCH(key, "headers")) {
                                zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addheaders", NULL, *opt);
-                       } else if (!strcmp(key.str, "cookies")) {
+                       } else if (KEYMATCH(key, "cookies")) {
                                zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addcookies", NULL, *opt);
-                       } else if (!strcmp(key.str, "ssl")) {
+                       } else if (KEYMATCH(key, "ssl")) {
                                zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addssloptions", NULL, *opt);
-                       } else if ((!strcasecmp(key.str, "url")) || (!strcasecmp(key.str, "uri"))) {
+                       } else if (KEYMATCH(key, "url") || KEYMATCH(key, "uri")) {
                                zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "seturl", NULL, *opt);
-                       } else if (!strcmp(key.str, "method")) {
+                       } else if (KEYMATCH(key, "method")) {
                                zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "setmethod", NULL, *opt);
 #if HTTP_CURL_VERSION(7,14,1)
-                       } else if (!strcmp(key.str, "resetcookies")) {
+                       } else if (KEYMATCH(key, "resetcookies")) {
                                getObject(http_request_object, obj);
                                http_request_reset_cookies(obj->request, 0);
 #endif
-                       } else if (!strcmp(key.str, "enablecookies")) {
+                       } else if (KEYMATCH(key, "enablecookies")) {
                                getObject(http_request_object, obj);
                                http_request_enable_cookies(obj->request);
-                       } else if (!strcasecmp(key.str, "recordHistory")) {
+                       } else if (KEYMATCH(key, "recordHistory")) {
                                zend_update_property_bool(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, 1 TSRMLS_CC);
+                       } else if (Z_TYPE_PP(opt) == IS_NULL) {
+                               old_opts = zend_read_property(THIS_CE, getThis(), ZEND_STRS("options")-1, 0 TSRMLS_CC);
+                               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);