X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_request_object.c;h=45625f0f777ab4dbf1fa0be4d5e229ed5818e591;hb=dd199f9961262ed43fa544240df15a9d6d7d0f08;hp=1c0f39a6b106774320dcb785e58b851a9b1e71c9;hpb=f51ba0ea2cab12b66e684a803197c0aad4d34f67;p=m6w6%2Fext-http diff --git a/http_request_object.c b/http_request_object.c index 1c0f39a..45625f0 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -72,6 +72,11 @@ HTTP_BEGIN_ARGS(addCookies, 1) HTTP_ARG_VAL(cookies, 0) HTTP_END_ARGS; +HTTP_EMPTY_ARGS(enableCookies); +#if HTTP_CURL_VERSION(7,14,1) +HTTP_EMPTY_ARGS(resetCookies); +#endif + HTTP_EMPTY_ARGS(getUrl); HTTP_BEGIN_ARGS(setUrl, 1) HTTP_ARG_VAL(url, 0) @@ -251,6 +256,11 @@ zend_function_entry http_request_object_fe[] = { HTTP_REQUEST_ME(getCookies, ZEND_ACC_PUBLIC) HTTP_REQUEST_ME(setCookies, ZEND_ACC_PUBLIC) + HTTP_REQUEST_ME(enableCookies, ZEND_ACC_PUBLIC) +#if HTTP_CURL_VERSION(7,14,1) + HTTP_REQUEST_ME(resetCookies, ZEND_ACC_PUBLIC) +#endif + HTTP_REQUEST_ME(setMethod, ZEND_ACC_PUBLIC) HTTP_REQUEST_ME(getMethod, ZEND_ACC_PUBLIC) @@ -524,7 +534,7 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ { case HTTP_GET: case HTTP_HEAD: - break; + break; case HTTP_PUT: { @@ -544,8 +554,8 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ status = FAILURE; } } + break; } - break; case HTTP_POST: default: @@ -571,8 +581,8 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ } } } + break; } - break; } if (status == SUCCESS) { @@ -868,6 +878,11 @@ PHP_METHOD(HttpRequest, setOptions) zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "seturl", NULL, *opt); } else if (!strcmp(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, "resetcookies")) { + getObject(http_request_object, obj); + http_request_reset_cookies(obj->request); +#endif } else { ZVAL_ADDREF(*opt); add_assoc_zval(add_opts, key, *opt); @@ -1030,6 +1045,35 @@ PHP_METHOD(HttpRequest, getCookies) } /* }}} */ +/* {{{ proto bool HttpRequest::enableCookies() + * + * Enable automatic sending of received cookies. + * Note that cuutomly set cookies will be sent anyway. + */ +PHP_METHOD(HttpRequest, enableCookies) +{ + NO_ARGS { + getObject(http_request_object, obj); + RETURN_SUCCESS(http_request_enable_cookies(obj->request)); + } + +} +/* }}} */ + +/* {{{ proto bool HttpRequest::resetCookies() + * + * Reset all automatically received/sent cookies. + * Note that customly set cookies are not affected. + */ +PHP_METHOD(HttpRequest, resetCookies) +{ + NO_ARGS { + getObject(http_request_object, obj); + RETURN_SUCCESS(http_request_reset_cookies(obj->request)); + } +} +/* }}} */ + /* {{{ proto bool HttpRequest::setUrl(string url) * * Set the request URL.