- cookies: array, list of cookies as associative array<br />
like array("cookie" => "value")<br />
- encodecookies: bool, whether to urlencode the cookies (default: true)<br />
- - resetcookies: bool, wheter to reset the cookies<br />
- cookiestore: string, path to a file where cookies are/will be stored<br />
- - cookiesession: bool, accept (true) or reset (false) sessioncookies<br />
+ - cookiesession: bool, don't load session cookies from cookiestore if TRUE<br />
- resume: int, byte offset to start the download from;<br />
if the server supports ranges<br />
- range: array, array of arrays, each containing two integers,<br />
<h3 id="HttpRequest_getCookies">array HttpRequest::getCookies()</h3>
<p>Get previously set cookies.</p>
<p>Returns an associative array containing any previously set cookies.</p>
+<h3 id="HttpRequest_enableCookies">bool HttpRequest::enableCookies()</h3>
+<p>Enable automatic sending of received cookies.<br />
+Note that cuutomly set cookies will be sent anyway.</p>
+<h3 id="HttpRequest_resetCookies">bool HttpRequest::resetCookies()</h3>
+<p>Reset all automatically received/sent cookies.<br />
+Note that customly set cookies are not affected.</p>
<h3 id="HttpRequest_setUrl">bool HttpRequest::setUrl(string url)</h3>
<p>Set the request URL.</p>
<p>Expects a string as parameter specifying the request url.</p>
<li><a href="#HttpRequest_setCookies">HttpRequest::setCookies()</a></li>
<li><a href="#HttpRequest_addCookies">HttpRequest::addCookies()</a></li>
<li><a href="#HttpRequest_getCookies">HttpRequest::getCookies()</a></li>
+<li><a href="#HttpRequest_enableCookies">HttpRequest::enableCookies()</a></li>
+<li><a href="#HttpRequest_resetCookies">HttpRequest::resetCookies()</a></li>
<li><a href="#HttpRequest_setUrl">HttpRequest::setUrl()</a></li>
<li><a href="#HttpRequest_getUrl">HttpRequest::getUrl()</a></li>
<li><a href="#HttpRequest_setMethod">HttpRequest::setMethod()</a></li>
</li>
</ul>
</div>
- <p><b>Generated at: Fri, 19 May 2006 16:55:19 +0200</b></p>
+ <p><b>Generated at: Mon, 22 May 2006 11:19:25 +0200</b></p>
</body>
</html>
* - cookies: array, list of cookies as associative array
* like array("cookie" => "value")
* - encodecookies: bool, whether to urlencode the cookies (default: true)
- * - resetcookies: bool, wheter to reset the cookies
* - cookiestore: string, path to a file where cookies are/will be stored
- * - cookiesession: bool, accept (true) or reset (false) sessioncookies
+ * - cookiesession: bool, don't load session cookies from cookiestore if TRUE
* - resume: int, byte offset to start the download from;
* if the server supports ranges
* - range: array, array of arrays, each containing two integers,
}
/* }}} */
+/* {{{ STATUS http_request_enable_cookies(http_request *) */
+PHP_HTTP_API STATUS _http_request_enable_cookies(http_request *request)
+{
+ TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
+ if (CURLE_OK == curl_easy_setopt(request->ch, CURLOPT_COOKIEFILE, "")) {
+ return SUCCESS;
+ }
+ http_error(HE_WARNING, HTTP_E_REQUEST, "Could not enable cookies for this session");
+ return FAILURE;
+}
+/* }}} */
+
+/* {{{ STATUS http_request_reset_cookies(http_request *) */
+PHP_HTTP_API STATUS _http_request_reset_cookies(http_request *request)
+{
+ TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
+#if HTTP_CURL_VERSION(7,14,1)
+ if (CURLE_OK == curl_easy_setopt(request->ch, CURLOPT_COOKIELIST, "ALL")) {
+ return SUCCESS;
+ }
+#endif
+ http_error(HE_WARNING, HTTP_E_REQUEST, "Could not reset cookies");
+ return FAILURE;
+}
+/* }}} */
+
/* {{{ void http_request_defaults(http_request *) */
PHP_HTTP_API void _http_request_defaults(http_request *request)
{
}
}
- /* session cookies */
- if ((zoption = http_request_option(request, options, "cookiesession", IS_BOOL))) {
- if (Z_BVAL_P(zoption)) {
- /* accept cookies for this session */
- HTTP_CURL_OPT(CURLOPT_COOKIEFILE, "");
- } else {
- /* don't load session cookies from cookiestore */
- HTTP_CURL_OPT(CURLOPT_COOKIESESSION, 1);
- }
+ /* don't load session cookies from cookiestore */
+ if ((zoption = http_request_option(request, options, "cookiesession", IS_BOOL)) && Z_BVAL_P(zoption)) {
+ HTTP_CURL_OPT(CURLOPT_COOKIESESSION, 1);
}
/* cookiestore, read initial cookies from that file and store cookies back into that file */
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_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
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)
{
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);
}
/* }}} */
-#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)
*
#define http_request_reset(r) _http_request_reset(r)
PHP_HTTP_API void _http_request_reset(http_request *r);
+#define http_request_enable_cookies(r) _http_request_enable_cookies(r)
+PHP_HTTP_API STATUS _http_request_enable_cookies(http_request *request);
+
+#define http_request_reset_cookies(r) _http_request_reset_cookies(r)
+PHP_HTTP_API STATUS _http_request_reset_cookies(http_request *request);
+
#define http_request_defaults(r) _http_request_defaults(r)
PHP_HTTP_API void _http_request_defaults(http_request *request);
PHP_METHOD(HttpRequest, addCookies);
PHP_METHOD(HttpRequest, getCookies);
PHP_METHOD(HttpRequest, setCookies);
-#if HTTP_CURL_VERSION(7,14,1)
+PHP_METHOD(HttpRequest, enableCookies);
PHP_METHOD(HttpRequest, resetCookies);
-#endif
PHP_METHOD(HttpRequest, setMethod);
PHP_METHOD(HttpRequest, getMethod);
PHP_METHOD(HttpRequest, setUrl);
echo "-TEST\n";
$r = new HttpRequest("http://dev.iworks.at/.cookie.php");
-$r->recordHistory = true;
$r->send();
$c[0] = $r->getResponseInfo("cookies");
var_dump(empty($c[0]));
-$r->setOptions(array("cookiesession" => true));
-
+$r->enableCookies();
$r->send();
$c[1] = $r->getResponseInfo("cookies");
var_dump(empty($c[1]));