X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_request_object.c;h=7b15faa42c2b7155845ee47fa158650dac602f4e;hb=6a15480b28d5aa21d86240cb92c90e5bc16cce5f;hp=45625f0f777ab4dbf1fa0be4d5e229ed5818e591;hpb=dd199f9961262ed43fa544240df15a9d6d7d0f08;p=m6w6%2Fext-http diff --git a/http_request_object.c b/http_request_object.c index 45625f0..7b15faa 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -74,7 +74,9 @@ HTTP_END_ARGS; HTTP_EMPTY_ARGS(enableCookies); #if HTTP_CURL_VERSION(7,14,1) -HTTP_EMPTY_ARGS(resetCookies); +HTTP_BEGIN_ARGS(resetCookies, 0) + HTTP_ARG_VAL(session_only, 0) +HTTP_END_ARGS; #endif HTTP_EMPTY_ARGS(getUrl); @@ -232,10 +234,12 @@ HTTP_BEGIN_ARGS(methodExists, 1) HTTP_ARG_VAL(method, 0) HTTP_END_ARGS; +#ifdef HAVE_CURL_GETFORMDATA HTTP_BEGIN_ARGS(encodeBody, 2) HTTP_ARG_VAL(fields, 0) HTTP_ARG_VAL(files, 0) HTTP_END_ARGS; +#endif #define OBJ_PROP_CE http_request_object_ce zend_class_entry *http_request_object_ce; @@ -321,9 +325,9 @@ zend_function_entry http_request_object_fe[] = { HTTP_REQUEST_ALIAS(methodUnregister, http_request_method_unregister) HTTP_REQUEST_ALIAS(methodName, http_request_method_name) HTTP_REQUEST_ALIAS(methodExists, http_request_method_exists) - +#ifdef HAVE_CURL_GETFORMDATA HTTP_REQUEST_ALIAS(encodeBody, http_request_body_encode) - +#endif EMPTY_FUNCTION_ENTRY }; static zend_object_handlers http_request_object_handlers; @@ -881,8 +885,13 @@ PHP_METHOD(HttpRequest, setOptions) #if HTTP_CURL_VERSION(7,14,1) } else if (!strcmp(key, "resetcookies")) { getObject(http_request_object, obj); - http_request_reset_cookies(obj->request); + 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); @@ -1060,17 +1069,26 @@ PHP_METHOD(HttpRequest, enableCookies) } /* }}} */ -/* {{{ proto bool HttpRequest::resetCookies() +/* {{{ 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) { - NO_ARGS { - getObject(http_request_object, obj); - RETURN_SUCCESS(http_request_reset_cookies(obj->request)); + 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)); } /* }}} */