+/* {{{ STATUS http_request_enable_cookies(http_request *) */
+PHP_HTTP_API STATUS _http_request_enable_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 (initialized && 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 *, int) */
+PHP_HTTP_API STATUS _http_request_reset_cookies(http_request *request, int session_only)
+{
+ 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 (session_only) {
+#if HTTP_CURL_VERSION(7,15,4)
+ if (initialized && CURLE_OK == curl_easy_setopt(request->ch, CURLOPT_COOKIELIST, "SESS")) {
+ return SUCCESS;
+ }
+#endif
+ http_error(HE_WARNING, HTTP_E_REQUEST, "Could not reset session cookies (need libcurl >= v7.15.4)");
+ } else {
+#if HTTP_CURL_VERSION(7,14,1)
+ if (initialized && CURLE_OK == curl_easy_setopt(request->ch, CURLOPT_COOKIELIST, "ALL")) {
+ return SUCCESS;
+ }
+#endif
+ http_error(HE_WARNING, HTTP_E_REQUEST, "Could not reset cookies (need libcurl >= v7.14.1)");
+ }
+ return FAILURE;
+}
+/* }}} */
+
+/* {{{ void http_request_defaults(http_request *) */
+PHP_HTTP_API void _http_request_defaults(http_request *request)
+{
+ if (request->ch) {
+ HTTP_CURL_OPT(CURLOPT_PROGRESSFUNCTION, NULL);
+ HTTP_CURL_OPT(CURLOPT_URL, NULL);
+ HTTP_CURL_OPT(CURLOPT_NOPROGRESS, 1L);
+ HTTP_CURL_OPT(CURLOPT_PROXY, NULL);
+ HTTP_CURL_OPT(CURLOPT_PROXYPORT, 0L);
+ HTTP_CURL_OPT(CURLOPT_PROXYTYPE, 0L);
+ HTTP_CURL_OPT(CURLOPT_PROXYUSERPWD, NULL);
+ HTTP_CURL_OPT(CURLOPT_PROXYAUTH, 0L);
+ HTTP_CURL_OPT(CURLOPT_DNS_CACHE_TIMEOUT, 60L);
+ HTTP_CURL_OPT(CURLOPT_IPRESOLVE, 0);
+ HTTP_CURL_OPT(CURLOPT_LOW_SPEED_LIMIT, 0L);
+ HTTP_CURL_OPT(CURLOPT_LOW_SPEED_TIME, 0L);
+#if HTTP_CURL_VERSION(7,15,5)
+ HTTP_CURL_OPT(CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t) 0);
+ HTTP_CURL_OPT(CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t) 0);
+#endif
+ /* crashes
+ HTTP_CURL_OPT(CURLOPT_MAXCONNECTS, 5L); */
+ HTTP_CURL_OPT(CURLOPT_FRESH_CONNECT, 0L);
+ HTTP_CURL_OPT(CURLOPT_FORBID_REUSE, 0L);
+ HTTP_CURL_OPT(CURLOPT_INTERFACE, NULL);
+ HTTP_CURL_OPT(CURLOPT_PORT, 0L);
+#if HTTP_CURL_VERSION(7,15,2)
+ HTTP_CURL_OPT(CURLOPT_LOCALPORT, 0L);
+ HTTP_CURL_OPT(CURLOPT_LOCALPORTRANGE, 0L);
+#endif
+ HTTP_CURL_OPT(CURLOPT_USERPWD, NULL);
+ HTTP_CURL_OPT(CURLOPT_HTTPAUTH, 0L);
+ HTTP_CURL_OPT(CURLOPT_ENCODING, NULL);
+ HTTP_CURL_OPT(CURLOPT_FOLLOWLOCATION, 0L);
+ HTTP_CURL_OPT(CURLOPT_UNRESTRICTED_AUTH, 0L);
+ HTTP_CURL_OPT(CURLOPT_REFERER, NULL);
+ HTTP_CURL_OPT(CURLOPT_USERAGENT, "PECL::HTTP/" PHP_EXT_HTTP_VERSION " (PHP/" PHP_VERSION ")");
+ HTTP_CURL_OPT(CURLOPT_HTTPHEADER, NULL);
+ HTTP_CURL_OPT(CURLOPT_COOKIE, NULL);
+#if HTTP_CURL_VERSION(7,14,1)
+ HTTP_CURL_OPT(CURLOPT_COOKIELIST, NULL);
+#endif
+ HTTP_CURL_OPT(CURLOPT_RANGE, NULL);
+ HTTP_CURL_OPT(CURLOPT_RESUME_FROM, 0L);
+ HTTP_CURL_OPT(CURLOPT_MAXFILESIZE, 0L);
+ HTTP_CURL_OPT(CURLOPT_TIMECONDITION, 0L);
+ HTTP_CURL_OPT(CURLOPT_TIMEVALUE, 0L);
+ HTTP_CURL_OPT(CURLOPT_TIMEOUT, 0L);
+ HTTP_CURL_OPT(CURLOPT_CONNECTTIMEOUT, 3);
+ HTTP_CURL_OPT(CURLOPT_SSLCERT, NULL);
+ HTTP_CURL_OPT(CURLOPT_SSLCERTTYPE, NULL);
+ HTTP_CURL_OPT(CURLOPT_SSLCERTPASSWD, NULL);
+ HTTP_CURL_OPT(CURLOPT_SSLKEY, NULL);
+ HTTP_CURL_OPT(CURLOPT_SSLKEYTYPE, NULL);
+ HTTP_CURL_OPT(CURLOPT_SSLKEYPASSWD, NULL);
+ HTTP_CURL_OPT(CURLOPT_SSLENGINE, NULL);
+ HTTP_CURL_OPT(CURLOPT_SSLVERSION, 0L);
+ HTTP_CURL_OPT(CURLOPT_SSL_VERIFYPEER, 0L);
+ HTTP_CURL_OPT(CURLOPT_SSL_VERIFYHOST, 0L);
+ HTTP_CURL_OPT(CURLOPT_SSL_CIPHER_LIST, NULL);
+#ifdef HTTP_CURL_CAINFO
+ HTTP_CURL_OPT(CURLOPT_CAINFO, HTTP_CURL_CAINFO);
+#else
+ HTTP_CURL_OPT(CURLOPT_CAINFO, NULL);