+/* {{{ proto void HttpRequest::unsetOptions()
+ *
+ * Unset all options/headers/cookies.
+ */
+PHP_METHOD(HttpRequest, unsetOptions)
+{
+ getObject(http_request_object, obj);
+
+ NO_ARGS;
+
+ FREE_PARR(obj, options);
+ INIT_PARR(obj, options);
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::setSslOptions(array options)
+ *
+ * Set additional SSL options.
+ */
+PHP_METHOD(HttpRequest, setSslOptions)
+{
+ zval *opts, *old_opts, **ssl_options;
+ getObject(http_request_object, obj);
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &opts)) {
+ RETURN_FALSE;
+ }
+
+ old_opts = GET_PROP(obj, options);
+
+ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(old_opts), "ssl", sizeof("ssl"), (void **) &ssl_options)) {
+ array_merge(opts, *ssl_options);
+ } else {
+ zval_add_ref(&opts);
+ add_assoc_zval(old_opts, "ssl", opts);
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto array HttpRequest::getSslOtpions()
+ *
+ * Get previously set SSL options.
+ */
+PHP_METHOD(HttpRequest, getSslOptions)
+{
+ zval *opts, **ssl_options;
+ getObject(http_request_object, obj);
+
+ NO_ARGS;
+
+ opts = GET_PROP(obj, options);
+
+ array_init(return_value);
+
+ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(opts), "ssl", sizeof("ssl"), (void **) &ssl_options)) {
+ array_copy(*ssl_options, return_value);
+ }
+}
+/* }}} */
+
+/* {{{ proto void HttpRequest::unsetSslOptions()
+ *
+ * Unset previously set SSL options.
+ */
+PHP_METHOD(HttpRequest, unsetSslOptions)
+{
+ zval *opts;
+ getObject(http_request_object, obj);
+
+ NO_ARGS;
+
+ opts = GET_PROP(obj, options);
+ zend_hash_del(Z_ARRVAL_P(opts), "ssl", sizeof("ssl"));
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::addHeaders(array headers)
+ *
+ * Add request header name/value pairs.
+ */
+PHP_METHOD(HttpRequest, addHeaders)
+{
+ zval *opts, **headers, *new_headers;
+ getObject(http_request_object, obj);
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &new_headers)) {
+ RETURN_FALSE;
+ }
+
+ opts = GET_PROP(obj, options);
+
+ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(opts), "headers", sizeof("headers"), (void **) &headers)) {
+ array_merge(new_headers, *headers);
+ } else {
+ zval_add_ref(&new_headers);
+ add_assoc_zval(opts, "headers", new_headers);
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto array HttpRequest::getHeaders()
+ *
+ * Get previously set request headers.
+ */
+PHP_METHOD(HttpRequest, getHeaders)
+{
+ zval *opts, **headers;
+ getObject(http_request_object, obj);
+
+ NO_ARGS;
+
+ opts = GET_PROP(obj, options);
+
+ array_init(return_value);
+
+ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(opts), "headers", sizeof("headers"), (void **) &headers)) {
+ array_copy(*headers, return_value);
+ }
+}
+/* }}} */
+
+/* {{{ proto void HttpRequest::unsetHeaders()
+ *
+ * Unset previously set request headers.
+ */
+PHP_METHOD(HttpRequest, unsetHeaders)
+{
+ zval *opts;
+ getObject(http_request_object, obj);
+
+ NO_ARGS;
+
+ opts = GET_PROP(obj, options);
+ zend_hash_del(Z_ARRVAL_P(opts), "headers", sizeof("headers"));
+}
+/* }}} */
+
+/* {{{ proto bool HttpRequest::addCookies(array cookies)
+ *
+ * Add cookies.
+ */
+PHP_METHOD(HttpRequest, addCookies)
+{
+ zval *opts, **cookies, *new_cookies;
+ getObject(http_request_object, obj);
+
+ if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &new_cookies)) {
+ RETURN_FALSE;
+ }
+
+ opts = GET_PROP(obj, options);
+
+ if (SUCCESS == zend_hash_find(Z_ARRVAL_P(opts), "cookies", sizeof("cookies"), (void **) &cookies)) {
+ array_merge(new_cookies, *cookies);
+ } else {
+ zval_add_ref(&new_cookies);
+ add_assoc_zval(opts, "cookies", new_cookies);
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto array HttpRequest::getCookies()