- FOREACH_KEYVAL(pos, opts, key, idx, opt) {
- if (key) {
- if (!strcmp(key, "headers")) {
- zval **headers;
- if (SUCCESS == zend_hash_find(Z_ARRVAL_P(new_opts), "headers", sizeof("headers"), (void **) &headers)) {
- convert_to_array_ex(opt);
- convert_to_array(*headers);
- array_merge(*opt, *headers);
- continue;
- }
- } else if (!strcmp(key, "cookies")) {
- zval **cookies;
- if (SUCCESS == zend_hash_find(Z_ARRVAL_P(new_opts), "cookies", sizeof("cookies"), (void **) &cookies)) {
- convert_to_array_ex(opt);
- convert_to_array(*cookies);
- array_merge(*opt, *cookies);
- continue;
- }
- } else if (!strcmp(key, "ssl")) {
- zval **ssl;
- if (SUCCESS == zend_hash_find(Z_ARRVAL_P(new_opts), "ssl", sizeof("ssl"), (void **) &ssl)) {
- convert_to_array_ex(opt);
- convert_to_array(*ssl);
- array_merge(*opt, *ssl);
- continue;
- }
- } else if ((Z_TYPE_PP(opt) == IS_STRING) && ((!strcasecmp(key, "url")) || (!strcasecmp(key, "uri")))) {
- UPD_STRL(obj, url, Z_STRVAL_PP(opt), Z_STRLEN_PP(opt));
- continue;
- } else if (!strcmp(key, "method")) {
- if (Z_TYPE_PP(opt) != IS_LONG) {
- convert_to_long_ex(opt);
- }
- UPD_PROP(obj, long, method, Z_LVAL_PP(opt));
- continue;
+ FOREACH_KEYVAL(pos, opts, key, opt) {
+ if (key.type == HASH_KEY_IS_STRING) {
+ if (!strcmp(key.str, "headers")) {
+ zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addheaders", NULL, *opt);
+ } else if (!strcmp(key.str, "cookies")) {
+ zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "addcookies", NULL, *opt);
+ } else if (!strcmp(key.str, "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"))) {
+ zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "seturl", NULL, *opt);
+ } else if (!strcmp(key.str, "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")) {
+ getObject(http_request_object, obj);
+ http_request_reset_cookies(obj->request, 0);
+#endif
+ } else if (!strcmp(key.str, "enablecookies")) {
+ getObject(http_request_object, obj);
+ http_request_enable_cookies(obj->request);
+ } else if (!strcasecmp(key.str, "recordHistory")) {
+ UPD_PROP(bool, recordHistory, 1);
+ } else {
+ ZVAL_ADDREF(*opt);
+ add_assoc_zval_ex(add_opts, key.str, key.len, *opt);