+/* {{{ proto void HTTPi_Request::__destruct()
+ *
+ */
+PHP_METHOD(HTTPi_Request, __destruct)
+{
+ getObject(httpi_request_object, obj);
+
+ NO_ARGS;
+
+ FREE_PARR(obj, options);
+ FREE_PARR(obj, responseInfo);
+ FREE_PARR(obj, responseData);
+}
+/* }}} */
+
+/* {{{ proto bool HTTPi_Request::setOptions(array options)
+ *
+ */
+PHP_METHOD(HTTPi_Request, setOptions)
+{
+ zval *opts, *old_opts, **opt;
+ getObject(httpi_request_object, obj);
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &opts)) {
+ RETURN_FALSE;
+ }
+
+ old_opts = GET_PROP(obj, options);
+
+ /* headers and cookies need extra attention -- thus cannot use zend_hash_merge() or php_array_merge() directly */
+ for ( zend_hash_internal_pointer_reset(Z_ARRVAL_P(opts));
+ zend_hash_get_current_data(Z_ARRVAL_P(opts), (void **) &opt) == SUCCESS;
+ zend_hash_move_forward(Z_ARRVAL_P(opts))) {
+ char *key;
+ long idx;
+ if (HASH_KEY_IS_STRING == zend_hash_get_current_key(Z_ARRVAL_P(opts), &key, &idx, 0)) {
+ if (!strcmp(key, "headers")) {
+ zval **headers;
+ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(old_opts), "headers", sizeof("headers"), (void **) &headers)) {
+ array_merge(*opt, *headers);
+ continue;
+ }
+ } else if (!strcmp(key, "cookies")) {
+ zval **cookies;
+ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(old_opts), "cookies", sizeof("cookies"), (void **) &cookies)) {
+ array_merge(*opt, *cookies);
+ continue;
+ }
+ }
+ zval_add_ref(opt);
+ add_assoc_zval(old_opts, key, *opt);
+ }
+ }
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto array HTTPi_Request::getOptions()
+ *
+ */
+PHP_METHOD(HTTPi_Request, getOptions)
+{
+ zval *opts;
+ getObject(httpi_request_object, obj);
+
+ NO_ARGS;
+
+ opts = GET_PROP(obj, options);
+ array_init(return_value);
+ array_copy(opts, return_value);
+}
+/* }}} */
+
+/* {{{ proto bool HTTPi_Request::setURL(string url)