X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_request_object.c;h=d90803db8ce87cdda5b273dd53d68b4b5202075f;hb=b3dd66ed1452139236b7101f7d73f19917bd1ea2;hp=7fa8ead74710fc894fb3d1cc983ee8a0ce537fad;hpb=2f39230d83bdf816dcae52c7e5a1b019347f0e7b;p=m6w6%2Fext-http diff --git a/http_request_object.c b/http_request_object.c index 7fa8ead..d90803d 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -72,6 +72,13 @@ 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_BEGIN_ARGS(resetCookies, 0) + HTTP_ARG_VAL(session_only, 0) +HTTP_END_ARGS; +#endif + HTTP_EMPTY_ARGS(getUrl); HTTP_BEGIN_ARGS(setUrl, 1) HTTP_ARG_VAL(url, 0) @@ -251,6 +258,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) @@ -868,6 +880,16 @@ 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, 0); +#endif + } else if (!strcmp(key, "enablecookies")) { + getObject(http_request_object, obj); + http_request_enable_cookies(obj->request); + } else if (!strcasecmp(key, "recordHistory")) { + UPD_PROP(bool, recordHistory, 1); } else { ZVAL_ADDREF(*opt); add_assoc_zval(add_opts, key, *opt); @@ -1030,6 +1052,44 @@ 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([bool session_only = FALSE]) + * + * Reset all automatically received/sent cookies. + * Note that customly set cookies are not affected. + * + * Accepts an optional bool parameter specifying + * whether only session cookies should be reset + * (needs libcurl >= v7.15.4, else libcurl >= v7.14.1). + * + * Returns TRUE on success, or FALSE on failure. + */ +PHP_METHOD(HttpRequest, resetCookies) +{ + zend_bool session_only = 0; + getObject(http_request_object, obj); + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &session_only)) { + RETURN_FALSE; + } + RETURN_SUCCESS(http_request_reset_cookies(obj->request, session_only)); +} +/* }}} */ + /* {{{ proto bool HttpRequest::setUrl(string url) * * Set the request URL.