mike Fri Feb 23 20:38:34 2007 UTC
Modified files:
/pecl/http http_request_object.c
Log:
- fix regressin
- optimize string cmp
http://cvs.php.net/viewvc.cgi/pecl/http/http_request_object.c?r1=1.157&r2=1.158&diff_format=u
Index: pecl/http/http_request_object.c
diff -u pecl/http/http_request_object.c:1.157
pecl/http/http_request_object.c:1.158
--- pecl/http/http_request_object.c:1.157 Fri Feb 23 08:13:15 2007
+++ pecl/http/http_request_object.c Fri Feb 23 20:38:34 2007
@@ -10,7 +10,7 @@
+--------------------------------------------------------------------+
*/
-/* $Id: http_request_object.c,v 1.157 2007/02/23 08:13:15 mike Exp $ */
+/* $Id: http_request_object.c,v 1.158 2007/02/23 20:38:34 mike Exp $ */
#define HTTP_WANT_CURL
#include "php_http.h"
@@ -888,34 +888,34 @@
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 @@
}
}
+ 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));
}
|