zval **bodyonly; \
\
/* check if only the body should be returned */ \
- if (options && (SUCCESS == zend_hash_find(Z_ARRVAL_P(options), "bodyonly", sizeof("bodyonly"), (void *) &bodyonly)) && zval_is_true(*bodyonly)) { \
+ if (options && (SUCCESS == zend_hash_find(Z_ARRVAL_P(options), "bodyonly", sizeof("bodyonly"), (void *) &bodyonly)) && i_zend_is_true(*bodyonly)) { \
http_message *msg = http_message_parse(PHPSTR_VAL(&request.conv.response), PHPSTR_LEN(&request.conv.response)); \
\
if (msg) { \
if (initialized && CURLE_OK == curl_easy_setopt(request->ch, CURLOPT_COOKIELIST, "SESS")) {
return SUCCESS;
}
-#endif
+#else
http_error(HE_WARNING, HTTP_E_REQUEST, "Could not reset session cookies (need libcurl >= v7.15.4)");
+#endif
} else {
#if HTTP_CURL_VERSION(7,14,1)
if (initialized && CURLE_OK == curl_easy_setopt(request->ch, CURLOPT_COOKIELIST, "ALL")) {
return SUCCESS;
}
-#endif
+#else
http_error(HE_WARNING, HTTP_E_REQUEST, "Could not reset cookies (need libcurl >= v7.14.1)");
+#endif
}
return FAILURE;
}
/* }}} */
+PHP_HTTP_API STATUS _http_request_flush_cookies(http_request *request)
+{
+ int initialized = 1;
+ TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
+
+ HTTP_CHECK_CURL_INIT(request->ch, http_curl_init_ex(request->ch, request), initialized = 0);
+#if HTTP_CURL_VERSION(7,17,1)
+ if (initialized && CURLE_OK == curl_easy_setopt(request->ch, CURLOPT_COOKIELIST, "FLUSH")) {
+ return SUCCESS;
+ }
+#else
+ http_error(HE_WARNING, HTTP_E_REQUEST, "Could not flush cookies (need libcurl >= v7.17.1)");
+#endif
+ return FAILURE;
+}
+
/* {{{ void http_request_defaults(http_request *) */
PHP_HTTP_API void _http_request_defaults(http_request *request)
{
HTTP_CURL_OPT(CURLOPT_USERPWD, NULL);
HTTP_CURL_OPT(CURLOPT_HTTPAUTH, 0L);
HTTP_CURL_OPT(CURLOPT_ENCODING, NULL);
+#if HTTP_CURL_VERSION(7,16,2)
+ /* we do this ourself anyway */
+ HTTP_CURL_OPT(CURLOPT_HTTP_CONTENT_DECODING, 0L);
+ HTTP_CURL_OPT(CURLOPT_HTTP_TRANSFER_DECODING, 0L);
+#endif
HTTP_CURL_OPT(CURLOPT_FOLLOWLOCATION, 0L);
HTTP_CURL_OPT(CURLOPT_UNRESTRICTED_AUTH, 0L);
HTTP_CURL_OPT(CURLOPT_REFERER, NULL);
switch (body->type) {
case HTTP_REQUEST_BODY_CURLPOST:
{
-#if defined(HAVE_CURL_FORMGET)
+#ifdef HAVE_CURL_FORMGET
phpstr str;
phpstr_init_ex(&str, 0x8000, 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(flushCookies);
HTTP_EMPTY_ARGS(getUrl);
HTTP_BEGIN_ARGS(setUrl, 1)
HTTP_ARG_VAL(method, 0)
HTTP_END_ARGS;
-#if defined(HAVE_CURL_GETFORMDATA) || defined(HAVE_CURL_FORMGET)
+#ifdef HAVE_CURL_FORMGET
HTTP_BEGIN_ARGS(encodeBody, 2)
HTTP_ARG_VAL(fields, 0)
HTTP_ARG_VAL(files, 0)
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(flushCookies, ZEND_ACC_PUBLIC)
HTTP_REQUEST_ME(setMethod, ZEND_ACC_PUBLIC)
HTTP_REQUEST_ME(getMethod, ZEND_ACC_PUBLIC)
HTTP_REQUEST_ALIAS(methodUnregister, http_request_method_unregister)
HTTP_REQUEST_ALIAS(methodName, http_request_method_name)
HTTP_REQUEST_ALIAS(methodExists, http_request_method_exists)
-#if defined(HAVE_CURL_GETFORMDATA) || defined(HAVE_CURL_FORMGET)
+#ifdef HAVE_CURL_FORMGET
HTTP_REQUEST_ALIAS(encodeBody, http_request_body_encode)
#endif
EMPTY_FUNCTION_ENTRY
if ( (Z_TYPE_P(options) != IS_ARRAY)
|| (SUCCESS != zend_hash_find(Z_ARRVAL_P(options), "onprogress", sizeof("onprogress"), (void *) &entry)
- || (!zval_is_true(*entry)))) {
+ || (!zend_is_callable(*entry, 0, NULL)))) {
MAKE_STD_ZVAL(pcb);
array_init(pcb);
ZVAL_ADDREF(getThis());
if ((msg = http_message_parse(PHPSTR_VAL(&obj->request->conv.response), PHPSTR_LEN(&obj->request->conv.response)))) {
zval *message;
- if (zval_is_true(zend_read_property(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, 0 TSRMLS_CC))) {
+ if (i_zend_is_true(zend_read_property(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, 0 TSRMLS_CC))) {
zval *hist, *history = zend_read_property(THIS_CE, getThis(), ZEND_STRS("history")-1, 0 TSRMLS_CC);
http_message *response = http_message_parse(PHPSTR_VAL(&obj->request->conv.response), PHPSTR_LEN(&obj->request->conv.response));
http_message *request = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request));
zend_update_property_string(THIS_CE, getThis(), ZEND_STRS("responseStatus")-1, "" TSRMLS_CC);
/* append request message to history */
- if (zval_is_true(zend_read_property(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, 0 TSRMLS_CC))) {
+ if (i_zend_is_true(zend_read_property(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, 0 TSRMLS_CC))) {
http_message *request;
if ((request = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request)))) {
zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "seturl", NULL, *opt);
} else if (KEYMATCH(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 (KEYMATCH(key, "flushcookies")) {
+ getObject(http_request_object, obj);
+ if (i_zend_is_true(*opt)) {
+ http_request_flush_cookies(obj->request);
+ }
} else if (KEYMATCH(key, "resetcookies")) {
getObject(http_request_object, obj);
- http_request_reset_cookies(obj->request, 0);
-#endif
+ http_request_reset_cookies(obj->request, (zend_bool) i_zend_is_true(*opt));
} else if (KEYMATCH(key, "enablecookies")) {
getObject(http_request_object, obj);
http_request_enable_cookies(obj->request);
} else if (KEYMATCH(key, "recordHistory")) {
- zend_update_property_bool(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, 1 TSRMLS_CC);
+ zend_update_property(THIS_CE, getThis(), ZEND_STRS("recordHistory")-1, *opt TSRMLS_CC);
} else if (Z_TYPE_PP(opt) == IS_NULL) {
old_opts = zend_read_property(THIS_CE, getThis(), ZEND_STRS("options")-1, 0 TSRMLS_CC);
if (Z_TYPE_P(old_opts) == IS_ARRAY) {
}
/* }}} */
+/* {{{ proto bool HttpRequest::flushCookies()
+ Flush internal cookies to the cookiestore file */
+PHP_METHOD(HttpRequest, flushCookies)
+{
+ NO_ARGS {
+ getObject(http_request_object, obj);
+ RETURN_SUCCESS(http_request_flush_cookies(obj->request));
+ }
+}
+/* }}} */
+
/* {{{ proto bool HttpRequest::setUrl(string url)
Set the request URL. */
PHP_METHOD(HttpRequest, setUrl)
getObjectEx(http_requestdatashare_object, obj, object);
SEPARATE_ZVAL_IF_NOT_REF(&value);
- status = http_request_datashare_set(obj->share, Z_STRVAL_P(member), Z_STRLEN_P(member), (zend_bool) zval_is_true(value));
+ status = http_request_datashare_set(obj->share, Z_STRVAL_P(member), Z_STRLEN_P(member), (zend_bool) i_zend_is_true(value));
if (orig != value) {
zval_ptr_dtor(&value);
value = orig;
}
/* capture mode */
- if (zval_is_true(*zend_std_get_static_property(THIS_CE, ZEND_STRS("catch")-1, 0 TSRMLS_CC))) {
+ if (i_zend_is_true(*zend_std_get_static_property(THIS_CE, ZEND_STRS("catch")-1, 0 TSRMLS_CC))) {
zval *etag_p, *the_data;
MAKE_STD_ZVAL(the_data);
}
/* caching */
- if (zval_is_true(*zend_std_get_static_property(THIS_CE, ZEND_STRS("cache")-1, 0 TSRMLS_CC))) {
+ if (i_zend_is_true(*zend_std_get_static_property(THIS_CE, ZEND_STRS("cache")-1, 0 TSRMLS_CC))) {
zval *cctl, *cctl_p, *etag, *etag_p, *lmod, *lmod_p;
etag = convert_to_type_ex(IS_STRING, *zend_std_get_static_property(THIS_CE, ZEND_STRS("eTag")-1, 0 TSRMLS_CC), &etag_p);
}
/* gzip */
- HTTP_G->send.deflate.response = zval_is_true(*zend_std_get_static_property(THIS_CE, ZEND_STRS("gzip")-1, 0 TSRMLS_CC));
+ HTTP_G->send.deflate.response = i_zend_is_true(*zend_std_get_static_property(THIS_CE, ZEND_STRS("gzip")-1, 0 TSRMLS_CC));
/* send */
switch (Z_LVAL_P(*zend_std_get_static_property(THIS_CE, ZEND_STRS("mode")-1, 0 TSRMLS_CC))) {
</lead>
<date>2007-09-26</date>
<version>
- <release>1.6.0b2</release>
+ <release>1.6.0RC1</release>
<api>1.6.0</api>
</version>
<stability>
</stability>
<license>BSD, revised</license>
<notes><![CDATA[
+1.6.0RC1:
++ Added HttpRequest::flushCookies() (libcurl >= 7.17.1)
+* Fixed problems with cookiestore request option introduced with persistent handles
+* Fixed crash on prematurely called HttpMessage::next()
+* Fixed possible shutdown crash with http_parse_params() and PHP4
+
+1.6.0b2:
+ Added constant HTTP_URL_FROM_ENV
-+ Added 'retrycount' and 'retrydelay' request options
-+ Added libevent support for libcurl (>= 7.16.0):
- o added --with-http-curl-libevent configure option
- o added HttpRequestPool::enableEvents()
* Fixed a possible crash at module shutdown in the persistent handle API
(probably fixing bug #11509)
* Fixed test suite for PHP4
* Fixed missing PHP_LIBDIR definition in config.m4 for PHP4
* Fixed non-standard shell support in config.m4
+
+1.6.0b1:
++ Added 'retrycount' and 'retrydelay' request options
++ Added libevent support for libcurl (>= 7.16.0):
+ o added --with-http-curl-libevent configure option
+ o added HttpRequestPool::enableEvents()
]]></notes>
<contents>
<dir name="/">
#define http_request_reset_cookies(r, s) _http_request_reset_cookies((r), (s))
PHP_HTTP_API STATUS _http_request_reset_cookies(http_request *request, int session_only);
+#define http_request_flush_cookies(r) _http_request_flush_cookies(r)
+PHP_HTTP_API STATUS _http_request_flush_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, setCookies);
PHP_METHOD(HttpRequest, enableCookies);
PHP_METHOD(HttpRequest, resetCookies);
+PHP_METHOD(HttpRequest, flushCookies);
PHP_METHOD(HttpRequest, setMethod);
PHP_METHOD(HttpRequest, getMethod);
PHP_METHOD(HttpRequest, setUrl);