- fix regressin
[m6w6/ext-http] / http_request_object.c
index 0c658126aad041f820b106e90154a19b7fb2a46c..7f427b8c0eda5e3a915dfa0e6543ef42ee6da730 100644 (file)
@@ -888,34 +888,34 @@ 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 */
        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);
                                }
@@ -926,6 +926,7 @@ 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));
        }