X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_request_object.c;h=b2d45fce920cd775e80069ce163e7a1985b7c059;hb=80842e67750ad9280770a7cfc956613207d46c1a;hp=7fa8ead74710fc894fb3d1cc983ee8a0ce537fad;hpb=2f39230d83bdf816dcae52c7e5a1b019347f0e7b;p=m6w6%2Fext-http diff --git a/http_request_object.c b/http_request_object.c index 7fa8ead..b2d45fc 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -72,6 +72,10 @@ HTTP_BEGIN_ARGS(addCookies, 1) HTTP_ARG_VAL(cookies, 0) HTTP_END_ARGS; +#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) @@ -250,6 +254,9 @@ zend_function_entry http_request_object_fe[] = { HTTP_REQUEST_ME(addCookies, ZEND_ACC_PUBLIC) HTTP_REQUEST_ME(getCookies, ZEND_ACC_PUBLIC) HTTP_REQUEST_ME(setCookies, 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) @@ -465,6 +472,13 @@ void _http_request_object_free(zend_object *object TSRMLS_DC) efree(o); } +#define http_request_object_resetcookies(o) _http_request_object_resetcookies((o) TSRMLS_CC) +static inline STATUS _http_request_object_resetcookies(zval *this_ptr TSRMLS_DC) +{ + getObject(http_request_object, obj); + return curl_easy_setopt(obj->request->ch, CURLOPT_COOKIELIST, "ALL"); +} + #define http_request_object_check_request_content_type(t) _http_request_object_check_request_content_type((t) TSRMLS_CC) static inline void _http_request_object_check_request_content_type(zval *this_ptr TSRMLS_DC) { @@ -868,6 +882,8 @@ 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); + } else if (!strcmp(key, "resetcookies")) { + http_request_object_resetcookies(getThis()); } else { ZVAL_ADDREF(*opt); add_assoc_zval(add_opts, key, *opt); @@ -1030,6 +1046,19 @@ PHP_METHOD(HttpRequest, getCookies) } /* }}} */ +#if HTTP_CURL_VERSION(7,14,1) +/* {{{ proto bool HttpRequest::resetCookies() + * + * Reset all cookies. Note that customly set cookies are not affected. + */ +PHP_METHOD(HttpRequest, resetCookies) +{ + NO_ARGS; + RETURN_SUCCESS(http_request_object_resetcookies(getThis())); +} +/* }}} */ +#endif + /* {{{ proto bool HttpRequest::setUrl(string url) * * Set the request URL.