* added HTTPi_Request::unsetOptions(), HTTPi_Request::addHeader(), HTTPi_Request...
authorMichael Wallner <mike@php.net>
Thu, 17 Mar 2005 14:45:41 +0000 (14:45 +0000)
committerMichael Wallner <mike@php.net>
Thu, 17 Mar 2005 14:45:41 +0000 (14:45 +0000)
http.c
http_methods.c
php_http.h

diff --git a/http.c b/http.c
index 30711e3ea3cb4414106df79bcc16561ccd6b6688..32d9e2aa85554197c93e07f7c033579eb0eaedd2 100644 (file)
--- a/http.c
+++ b/http.c
@@ -308,6 +308,10 @@ zend_function_entry httpi_request_class_methods[] = {
 
        PHP_ME(HTTPi_Request, setOptions, NULL, ZEND_ACC_PUBLIC)
        PHP_ME(HTTPi_Request, getOptions, NULL, ZEND_ACC_PUBLIC)
+       PHP_ME(HTTPi_Request, unsetOptions, NULL, ZEND_ACC_PUBLIC)
+       
+       PHP_ME(HTTPi_Request, addHeader, NULL, ZEND_ACC_PUBLIC)
+       PHP_ME(HTTPi_Request, addCookie, NULL, ZEND_ACC_PUBLIC)
 
        PHP_ME(HTTPi_Request, setMethod, NULL, ZEND_ACC_PUBLIC)
        PHP_ME(HTTPi_Request, getMethod, NULL, ZEND_ACC_PUBLIC)
@@ -530,7 +534,7 @@ PHP_MINFO_FUNCTION(http)
        php_info_print_table_row(2, "Extended HTTP support", "enabled");
        php_info_print_table_row(2, "Extension Version:", full_version_string);
        php_info_print_table_end();
-       
+
        php_info_print_table_start();
        php_info_print_table_header(2, "Functionality",            "Availability");
        php_info_print_table_row(2,    "Miscellaneous Utilities:", HTTP_FUNC_AVAIL("HTTPi"));
index 1365fcf4c6a15c7630908ecc1e6f91094e3cc6b1..e4042a11c9b805fcdae5051d74717cf43a653e48 100644 (file)
@@ -628,6 +628,73 @@ PHP_METHOD(HTTPi_Request, getOptions)
 }
 /* }}} */
 
+/* {{{ proto void HTTPi_Request::unsetOptions()
+ *
+ * Unset all options/headers/cookies.
+ */
+PHP_METHOD(HTTPi_Request, unsetOptions)
+{
+       getObject(httpi_request_object, obj);
+       
+       NO_ARGS;
+       
+       FREE_PARR(obj, options);
+       INIT_PARR(obj, options);
+}
+/* }}} */
+
+/* {{{ proto bool HTTPi_Request::addHeader(array header)
+ *
+ * Add (a) request header name/value pair(s).
+ */
+PHP_METHOD(HTTPi_Request, addHeader)
+{
+       zval *opts, **headers, *new_headers;
+       getObject(httpi_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 bool HTTPi_Request::addCookie(array cookie)
+ *
+ * Add (a) cookie(s).
+ */
+PHP_METHOD(HTTPi_Request, addCookie)
+{
+       zval *opts, **cookies, *new_cookies;
+       getObject(httpi_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 bool HTTPi_Request::setURL(string url)
  *
  * Set the request URL.
index ea2c2559e0262b81f666cb6f131567ac84d53996..3f1a6c2a348de4bd343d664673fae4c75dbdf4ee 100644 (file)
@@ -116,6 +116,9 @@ PHP_METHOD(HTTPi_Request, __construct);
 PHP_METHOD(HTTPi_Request, __destruct);
 PHP_METHOD(HTTPi_Request, setOptions);
 PHP_METHOD(HTTPi_Request, getOptions);
+PHP_METHOD(HTTPi_Request, unsetOptions);
+PHP_METHOD(HTTPi_Request, addHeader);
+PHP_METHOD(HTTPi_Request, addCookie);
 PHP_METHOD(HTTPi_Request, setMethod);
 PHP_METHOD(HTTPi_Request, getMethod);
 PHP_METHOD(HTTPi_Request, setURL);