X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_request_object.c;h=45625f0f777ab4dbf1fa0be4d5e229ed5818e591;hp=60935420a651332df6c027089e3512c694b26459;hb=dd199f9961262ed43fa544240df15a9d6d7d0f08;hpb=6c4aac679c57cea2e3f7524974509595dc1a31a2 diff --git a/http_request_object.c b/http_request_object.c index 6093542..45625f0 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -72,6 +72,7 @@ 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 @@ -254,6 +255,8 @@ 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) + + HTTP_REQUEST_ME(enableCookies, ZEND_ACC_PUBLIC) #if HTTP_CURL_VERSION(7,14,1) HTTP_REQUEST_ME(resetCookies, ZEND_ACC_PUBLIC) #endif @@ -472,15 +475,6 @@ void _http_request_object_free(zend_object *object TSRMLS_DC) efree(o); } -#if HTTP_CURL_VERSION(7,14,1) -#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"); -} -#endif - #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) { @@ -886,7 +880,8 @@ PHP_METHOD(HttpRequest, setOptions) 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")) { - http_request_object_resetcookies(getThis()); + getObject(http_request_object, obj); + http_request_reset_cookies(obj->request); #endif } else { ZVAL_ADDREF(*opt); @@ -1050,18 +1045,34 @@ PHP_METHOD(HttpRequest, getCookies) } /* }}} */ -#if HTTP_CURL_VERSION(7,14,1) +/* {{{ 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 cookies. Note that customly set cookies are not affected. + * Reset all automatically received/sent cookies. + * Note that customly set cookies are not affected. */ PHP_METHOD(HttpRequest, resetCookies) { - NO_ARGS; - RETURN_SUCCESS(http_request_object_resetcookies(getThis())); + NO_ARGS { + getObject(http_request_object, obj); + RETURN_SUCCESS(http_request_reset_cookies(obj->request)); + } } /* }}} */ -#endif /* {{{ proto bool HttpRequest::setUrl(string url) *