Lines Matching refs:ch

150 static void _php_curl_close_ex(php_curl *ch TSRMLS_DC);
167 static int php_curl_option_url(php_curl *ch, const char *url, const int len TSRMLS_DC) /* {{{ */ in php_curl_option_url() argument
182 error = curl_easy_setopt(ch->cp, CURLOPT_PROTOCOLS, CURLPROTO_ALL & ~CURLPROTO_FILE); in php_curl_option_url()
201 error = curl_easy_setopt(ch->cp, CURLOPT_URL, url); in php_curl_option_url()
204 error = curl_easy_setopt(ch->cp, CURLOPT_URL, copystr); in php_curl_option_url()
205 zend_llist_add_element(&ch->to_free->str, &copystr); in php_curl_option_url()
212 int _php_curl_verify_handlers(php_curl *ch, int reporterror TSRMLS_DC) /* {{{ */ in _php_curl_verify_handlers() argument
215 if (!ch || !ch->handlers) { in _php_curl_verify_handlers()
219 if (ch->handlers->std_err) { in _php_curl_verify_handlers()
220 …stream = (php_stream *) zend_fetch_resource(&ch->handlers->std_err TSRMLS_CC, -1, NULL, NULL, 2, p… in _php_curl_verify_handlers()
225 zval_ptr_dtor(&ch->handlers->std_err); in _php_curl_verify_handlers()
226 ch->handlers->std_err = NULL; in _php_curl_verify_handlers()
228 curl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr); in _php_curl_verify_handlers()
231 if (ch->handlers->read && ch->handlers->read->stream) { in _php_curl_verify_handlers()
232 …stream = (php_stream *) zend_fetch_resource(&ch->handlers->read->stream TSRMLS_CC, -1, NULL, NULL,… in _php_curl_verify_handlers()
237 zval_ptr_dtor(&ch->handlers->read->stream); in _php_curl_verify_handlers()
238 ch->handlers->read->fd = 0; in _php_curl_verify_handlers()
239 ch->handlers->read->fp = 0; in _php_curl_verify_handlers()
240 ch->handlers->read->stream = NULL; in _php_curl_verify_handlers()
242 curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch); in _php_curl_verify_handlers()
245 if (ch->handlers->write_header && ch->handlers->write_header->stream) { in _php_curl_verify_handlers()
246 …stream = (php_stream *) zend_fetch_resource(&ch->handlers->write_header->stream TSRMLS_CC, -1, NUL… in _php_curl_verify_handlers()
251 zval_ptr_dtor(&ch->handlers->write_header->stream); in _php_curl_verify_handlers()
252 ch->handlers->write_header->fp = 0; in _php_curl_verify_handlers()
253 ch->handlers->write_header->stream = NULL; in _php_curl_verify_handlers()
255 ch->handlers->write_header->method = PHP_CURL_IGNORE; in _php_curl_verify_handlers()
256 curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); in _php_curl_verify_handlers()
259 if (ch->handlers->write && ch->handlers->write->stream) { in _php_curl_verify_handlers()
260 …stream = (php_stream *) zend_fetch_resource(&ch->handlers->write->stream TSRMLS_CC, -1, NULL, NULL… in _php_curl_verify_handlers()
265 zval_ptr_dtor(&ch->handlers->write->stream); in _php_curl_verify_handlers()
266 ch->handlers->write->fp = 0; in _php_curl_verify_handlers()
267 ch->handlers->write->stream = NULL; in _php_curl_verify_handlers()
269 ch->handlers->write->method = PHP_CURL_STDOUT; in _php_curl_verify_handlers()
270 ch->handlers->write->type = PHP_CURL_ASCII; in _php_curl_verify_handlers()
271 curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch); in _php_curl_verify_handlers()
288 ZEND_ARG_INFO(0, ch)
292 ZEND_ARG_INFO(0, ch)
298 ZEND_ARG_INFO(0, ch)
303 ZEND_ARG_INFO(0, ch)
307 ZEND_ARG_INFO(0, ch)
312 ZEND_ARG_INFO(0, ch)
316 ZEND_ARG_INFO(0, ch)
320 ZEND_ARG_INFO(0, ch)
328 ZEND_ARG_INFO(0, ch)
333 ZEND_ARG_INFO(0, ch)
347 ZEND_ARG_INFO(0, ch)
999 php_curl *ch = (php_curl *) ctx; in curl_write() local
1000 php_curl_write *t = ch->handlers->write; in curl_write()
1002 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_write()
1029 ZVAL_RESOURCE(handle, ch->id); in curl_write()
1030 zend_list_addref(ch->id); in curl_write()
1047 ch->in_callback = 1; in curl_write()
1049 ch->in_callback = 0; in curl_write()
1054 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in curl_write()
1076 php_curl *ch = (php_curl *) clientp; in curl_progress() local
1077 php_curl_progress *t = ch->handlers->progress; in curl_progress()
1095 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_progress()
1122 ch->in_callback = 1; in curl_progress()
1124 ch->in_callback = 0; in curl_progress()
1128 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in curl_progress()
1152 php_curl *ch = (php_curl *) ctx; in curl_read() local
1153 php_curl_read *t = ch->handlers->read; in curl_read()
1170 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_read()
1176 ZVAL_RESOURCE(handle, ch->id); in curl_read()
1177 zend_list_addref(ch->id); in curl_read()
1196 ch->in_callback = 1; in curl_read()
1198 ch->in_callback = 0; in curl_read()
1205 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in curl_read()
1228 php_curl *ch = (php_curl *) ctx; in curl_write_header() local
1229 php_curl_write *t = ch->handlers->write_header; in curl_write_header()
1231 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_write_header()
1237 if (ch->handlers->write->method == PHP_CURL_RETURN && length > 0) { in curl_write_header()
1238 smart_str_appendl(&ch->handlers->write->buf, data, (int) length); in curl_write_header()
1256 ZVAL_RESOURCE(handle, ch->id); in curl_write_header()
1257 zend_list_addref(ch->id); in curl_write_header()
1273 ch->in_callback = 1; in curl_write_header()
1275 ch->in_callback = 0; in curl_write_header()
1280 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in curl_write_header()
1305 php_curl *ch = (php_curl *) ctx; in curl_debug() local
1308 if (ch->header.str_len) { in curl_debug()
1309 efree(ch->header.str); in curl_debug()
1312 ch->header.str = estrndup(buf, buf_len); in curl_debug()
1313 ch->header.str_len = buf_len; in curl_debug()
1326 php_curl *ch = (php_curl *) ctx; in curl_passwd() local
1327 zval *func = ch->handlers->passwd; in curl_passwd()
1332 TSRMLS_FETCH_FROM_CTX(ch->thread_ctx); in curl_passwd()
1338 ZVAL_RESOURCE(argv[0], ch->id); in curl_passwd()
1339 zend_list_addref(ch->id); in curl_passwd()
1435 static void alloc_curl_handle(php_curl **ch) in alloc_curl_handle() argument
1437 *ch = emalloc(sizeof(php_curl)); in alloc_curl_handle()
1438 (*ch)->to_free = ecalloc(1, sizeof(struct _php_curl_free)); in alloc_curl_handle()
1439 (*ch)->handlers = ecalloc(1, sizeof(php_curl_handlers)); in alloc_curl_handle()
1440 (*ch)->handlers->write = ecalloc(1, sizeof(php_curl_write)); in alloc_curl_handle()
1441 (*ch)->handlers->write_header = ecalloc(1, sizeof(php_curl_write)); in alloc_curl_handle()
1442 (*ch)->handlers->read = ecalloc(1, sizeof(php_curl_read)); in alloc_curl_handle()
1443 (*ch)->handlers->progress = ecalloc(1, sizeof(php_curl_progress)); in alloc_curl_handle()
1445 (*ch)->in_callback = 0; in alloc_curl_handle()
1446 (*ch)->header.str_len = 0; in alloc_curl_handle()
1448 memset(&(*ch)->err, 0, sizeof((*ch)->err)); in alloc_curl_handle()
1449 (*ch)->handlers->write->stream = NULL; in alloc_curl_handle()
1450 (*ch)->handlers->write_header->stream = NULL; in alloc_curl_handle()
1451 (*ch)->handlers->read->stream = NULL; in alloc_curl_handle()
1453 …zend_llist_init(&(*ch)->to_free->str, sizeof(char *), (llist_dtor_func_t) curl_free_s… in alloc_curl_handle()
1454 …zend_llist_init(&(*ch)->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t) curl_free_p… in alloc_curl_handle()
1456 (*ch)->to_free->slist = emalloc(sizeof(HashTable)); in alloc_curl_handle()
1457 zend_hash_init((*ch)->to_free->slist, 4, NULL, curl_free_slist, 0); in alloc_curl_handle()
1543 php_curl *ch; in PHP_FUNCTION() local
1560 alloc_curl_handle(&ch); in PHP_FUNCTION()
1561 TSRMLS_SET_CTX(ch->thread_ctx); in PHP_FUNCTION()
1563 ch->cp = cp; in PHP_FUNCTION()
1565 ch->handlers->write->method = PHP_CURL_STDOUT; in PHP_FUNCTION()
1566 ch->handlers->write->type = PHP_CURL_ASCII; in PHP_FUNCTION()
1567 ch->handlers->read->method = PHP_CURL_DIRECT; in PHP_FUNCTION()
1568 ch->handlers->write_header->method = PHP_CURL_IGNORE; in PHP_FUNCTION()
1570 ch->uses = 0; in PHP_FUNCTION()
1573 ch->clone = clone; in PHP_FUNCTION()
1575 curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1); in PHP_FUNCTION()
1576 curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); in PHP_FUNCTION()
1577 curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); in PHP_FUNCTION()
1578 curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write); in PHP_FUNCTION()
1579 curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch); in PHP_FUNCTION()
1580 curl_easy_setopt(ch->cp, CURLOPT_READFUNCTION, curl_read); in PHP_FUNCTION()
1581 curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch); in PHP_FUNCTION()
1582 curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header); in PHP_FUNCTION()
1583 curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); in PHP_FUNCTION()
1584 curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1); in PHP_FUNCTION()
1585 curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120); in PHP_FUNCTION()
1586 curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */ in PHP_FUNCTION()
1590 curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo); in PHP_FUNCTION()
1594 curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1); in PHP_FUNCTION()
1598 if (!php_curl_option_url(ch, url, url_len TSRMLS_CC)) { in PHP_FUNCTION()
1599 _php_curl_close_ex(ch TSRMLS_CC); in PHP_FUNCTION()
1604 ZEND_REGISTER_RESOURCE(return_value, ch, le_curl); in PHP_FUNCTION()
1605 ch->id = Z_LVAL_P(return_value); in PHP_FUNCTION()
1615 php_curl *ch, *dupch; in PHP_FUNCTION() local
1621 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
1623 cp = curl_easy_duphandle(ch->cp); in PHP_FUNCTION()
1634 ch->uses++; in PHP_FUNCTION()
1635 if (ch->handlers->write->stream) { in PHP_FUNCTION()
1636 Z_ADDREF_P(ch->handlers->write->stream); in PHP_FUNCTION()
1638 dupch->handlers->write->stream = ch->handlers->write->stream; in PHP_FUNCTION()
1639 dupch->handlers->write->method = ch->handlers->write->method; in PHP_FUNCTION()
1640 dupch->handlers->write->type = ch->handlers->write->type; in PHP_FUNCTION()
1641 if (ch->handlers->read->stream) { in PHP_FUNCTION()
1642 Z_ADDREF_P(ch->handlers->read->stream); in PHP_FUNCTION()
1644 dupch->handlers->read->stream = ch->handlers->read->stream; in PHP_FUNCTION()
1645 dupch->handlers->read->method = ch->handlers->read->method; in PHP_FUNCTION()
1646 dupch->handlers->write_header->method = ch->handlers->write_header->method; in PHP_FUNCTION()
1647 if (ch->handlers->write_header->stream) { in PHP_FUNCTION()
1648 Z_ADDREF_P(ch->handlers->write_header->stream); in PHP_FUNCTION()
1650 dupch->handlers->write_header->stream = ch->handlers->write_header->stream; in PHP_FUNCTION()
1652 dupch->handlers->write->fp = ch->handlers->write->fp; in PHP_FUNCTION()
1653 dupch->handlers->write_header->fp = ch->handlers->write_header->fp; in PHP_FUNCTION()
1654 dupch->handlers->read->fp = ch->handlers->read->fp; in PHP_FUNCTION()
1655 dupch->handlers->read->fd = ch->handlers->read->fd; in PHP_FUNCTION()
1657 if (ch->handlers->passwd) { in PHP_FUNCTION()
1658 zval_add_ref(&ch->handlers->passwd); in PHP_FUNCTION()
1659 dupch->handlers->passwd = ch->handlers->passwd; in PHP_FUNCTION()
1660 curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) dupch); in PHP_FUNCTION()
1663 if (ch->handlers->write->func_name) { in PHP_FUNCTION()
1664 zval_add_ref(&ch->handlers->write->func_name); in PHP_FUNCTION()
1665 dupch->handlers->write->func_name = ch->handlers->write->func_name; in PHP_FUNCTION()
1667 if (ch->handlers->read->func_name) { in PHP_FUNCTION()
1668 zval_add_ref(&ch->handlers->read->func_name); in PHP_FUNCTION()
1669 dupch->handlers->read->func_name = ch->handlers->read->func_name; in PHP_FUNCTION()
1671 if (ch->handlers->write_header->func_name) { in PHP_FUNCTION()
1672 zval_add_ref(&ch->handlers->write_header->func_name); in PHP_FUNCTION()
1673 dupch->handlers->write_header->func_name = ch->handlers->write_header->func_name; in PHP_FUNCTION()
1676 if (ch->handlers->progress->func_name) { in PHP_FUNCTION()
1677 zval_add_ref(&ch->handlers->progress->func_name); in PHP_FUNCTION()
1678 dupch->handlers->progress->func_name = ch->handlers->progress->func_name; in PHP_FUNCTION()
1680 dupch->handlers->progress->method = ch->handlers->progress->method; in PHP_FUNCTION()
1690 dupch->to_free = ch->to_free; in PHP_FUNCTION()
1693 Z_ADDREF_P(ch->clone); in PHP_FUNCTION()
1694 dupch->clone = ch->clone; in PHP_FUNCTION()
1701 static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *return_value TSRMLS_DC)… in _php_curl_setopt() argument
1713 error = curl_easy_setopt(ch->cp, option, 2); in _php_curl_setopt()
1810 error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); in _php_curl_setopt()
1816 error = curl_easy_setopt(ch->cp, option, (curl_off_t)Z_LVAL_PP(zvalue)); in _php_curl_setopt()
1828 error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); in _php_curl_setopt()
1833 error = curl_easy_setopt(ch->cp, CURLOPT_POSTREDIR, Z_LVAL_PP(zvalue) & CURL_REDIR_POST_ALL); in _php_curl_setopt()
1878 if (!php_curl_option_url(ch, Z_STRVAL_PP(zvalue), Z_STRLEN_PP(zvalue) TSRMLS_CC)) { in _php_curl_setopt()
1889 error = curl_easy_setopt(ch->cp, option, copystr); in _php_curl_setopt()
1890 zend_llist_add_element(&ch->to_free->str, &copystr); in _php_curl_setopt()
1894 error = curl_easy_setopt(ch->cp, option, Z_STRVAL_PP(zvalue)); in _php_curl_setopt()
1930 if (ch->handlers->write->stream) { in _php_curl_setopt()
1931 Z_DELREF_P(ch->handlers->write->stream); in _php_curl_setopt()
1934 ch->handlers->write->fp = fp; in _php_curl_setopt()
1935 ch->handlers->write->method = PHP_CURL_FILE; in _php_curl_setopt()
1936 ch->handlers->write->stream = *zvalue; in _php_curl_setopt()
1945 if (ch->handlers->write_header->stream) { in _php_curl_setopt()
1946 Z_DELREF_P(ch->handlers->write_header->stream); in _php_curl_setopt()
1949 ch->handlers->write_header->fp = fp; in _php_curl_setopt()
1950 ch->handlers->write_header->method = PHP_CURL_FILE; in _php_curl_setopt()
1951 ch->handlers->write_header->stream = *zvalue; in _php_curl_setopt()
1959 if (ch->handlers->read->stream) { in _php_curl_setopt()
1960 Z_DELREF_P(ch->handlers->read->stream); in _php_curl_setopt()
1963 ch->handlers->read->fp = fp; in _php_curl_setopt()
1964 ch->handlers->read->fd = Z_LVAL_PP(zvalue); in _php_curl_setopt()
1965 ch->handlers->read->stream = *zvalue; in _php_curl_setopt()
1969 if (ch->handlers->std_err) { in _php_curl_setopt()
1970 zval_ptr_dtor(&ch->handlers->std_err); in _php_curl_setopt()
1973 ch->handlers->std_err = *zvalue; in _php_curl_setopt()
1981 error = curl_easy_setopt(ch->cp, option, fp); in _php_curl_setopt()
1991 ch->handlers->write->method = PHP_CURL_RETURN; in _php_curl_setopt()
1993 ch->handlers->write->method = PHP_CURL_STDOUT; in _php_curl_setopt()
2000 ch->handlers->write->type = PHP_CURL_BINARY; in _php_curl_setopt()
2002 ch->handlers->write->type = PHP_CURL_ASCII; in _php_curl_setopt()
2006 if (ch->handlers->write->func_name) { in _php_curl_setopt()
2007 zval_ptr_dtor(&ch->handlers->write->func_name); in _php_curl_setopt()
2008 ch->handlers->write->fci_cache = empty_fcall_info_cache; in _php_curl_setopt()
2011 ch->handlers->write->func_name = *zvalue; in _php_curl_setopt()
2012 ch->handlers->write->method = PHP_CURL_USER; in _php_curl_setopt()
2015 if (ch->handlers->read->func_name) { in _php_curl_setopt()
2016 zval_ptr_dtor(&ch->handlers->read->func_name); in _php_curl_setopt()
2017 ch->handlers->read->fci_cache = empty_fcall_info_cache; in _php_curl_setopt()
2020 ch->handlers->read->func_name = *zvalue; in _php_curl_setopt()
2021 ch->handlers->read->method = PHP_CURL_USER; in _php_curl_setopt()
2024 curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION, curl_progress); in _php_curl_setopt()
2025 curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch); in _php_curl_setopt()
2026 if (ch->handlers->progress->func_name) { in _php_curl_setopt()
2027 zval_ptr_dtor(&ch->handlers->progress->func_name); in _php_curl_setopt()
2028 ch->handlers->progress->fci_cache = empty_fcall_info_cache; in _php_curl_setopt()
2031 ch->handlers->progress->func_name = *zvalue; in _php_curl_setopt()
2032 ch->handlers->progress->method = PHP_CURL_USER; in _php_curl_setopt()
2035 if (ch->handlers->write_header->func_name) { in _php_curl_setopt()
2036 zval_ptr_dtor(&ch->handlers->write_header->func_name); in _php_curl_setopt()
2037 ch->handlers->write_header->fci_cache = empty_fcall_info_cache; in _php_curl_setopt()
2040 ch->handlers->write_header->func_name = *zvalue; in _php_curl_setopt()
2041 ch->handlers->write_header->method = PHP_CURL_USER; in _php_curl_setopt()
2045 if (ch->handlers->passwd) { in _php_curl_setopt()
2046 zval_ptr_dtor(&ch->handlers->passwd); in _php_curl_setopt()
2049 ch->handlers->passwd = *zvalue; in _php_curl_setopt()
2050 error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDFUNCTION, curl_passwd); in _php_curl_setopt()
2051 error = curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) ch); in _php_curl_setopt()
2139 SAVE_CURL_ERROR(ch, error); in _php_curl_setopt()
2145 if (Z_REFCOUNT_P(ch->clone) <= 1) { in _php_curl_setopt()
2146 zend_llist_clean(&ch->to_free->post); in _php_curl_setopt()
2148 zend_llist_add_element(&ch->to_free->post, &first); in _php_curl_setopt()
2149 error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first); in _php_curl_setopt()
2155 error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, Z_STRLEN_PP(zvalue)); in _php_curl_setopt()
2156 error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, Z_STRVAL_PP(zvalue)); in _php_curl_setopt()
2162 zend_llist_add_element(&ch->to_free->str, &post); in _php_curl_setopt()
2164 error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, post); in _php_curl_setopt()
2165 error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, Z_STRLEN_PP(zvalue)); in _php_curl_setopt()
2198 …zend_hash_index_update(ch->to_free->slist, (ulong) option, &slist, sizeof(struct curl_slist *), NU… in _php_curl_setopt()
2200 error = curl_easy_setopt(ch->cp, option, slist); in _php_curl_setopt()
2223 error = curl_easy_setopt(ch->cp, option, Z_STRVAL_PP(zvalue)); in _php_curl_setopt()
2227 error = curl_easy_setopt(ch->cp, option, copystr); in _php_curl_setopt()
2228 zend_llist_add_element(&ch->to_free->str, &copystr); in _php_curl_setopt()
2235 curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, curl_debug); in _php_curl_setopt()
2236 curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *)ch); in _php_curl_setopt()
2237 curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 1); in _php_curl_setopt()
2239 curl_easy_setopt(ch->cp, CURLOPT_DEBUGFUNCTION, NULL); in _php_curl_setopt()
2240 curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, NULL); in _php_curl_setopt()
2241 curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0); in _php_curl_setopt()
2246 SAVE_CURL_ERROR(ch, error); in _php_curl_setopt()
2261 php_curl *ch; in PHP_FUNCTION() local
2267 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2274 if (!_php_curl_setopt(ch, options, zvalue, return_value TSRMLS_CC)) { in PHP_FUNCTION()
2287 php_curl *ch; in PHP_FUNCTION() local
2297 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2305 if (_php_curl_setopt(ch, (long) option, entry, return_value TSRMLS_CC)) { in PHP_FUNCTION()
2316 void _php_curl_cleanup_handle(php_curl *ch) in _php_curl_cleanup_handle() argument
2318 if (ch->handlers->write->buf.len > 0) { in _php_curl_cleanup_handle()
2319 smart_str_free(&ch->handlers->write->buf); in _php_curl_cleanup_handle()
2321 if (ch->header.str_len) { in _php_curl_cleanup_handle()
2322 efree(ch->header.str); in _php_curl_cleanup_handle()
2323 ch->header.str_len = 0; in _php_curl_cleanup_handle()
2326 memset(ch->err.str, 0, CURL_ERROR_SIZE + 1); in _php_curl_cleanup_handle()
2327 ch->err.no = 0; in _php_curl_cleanup_handle()
2337 php_curl *ch; in PHP_FUNCTION() local
2343 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2345 _php_curl_verify_handlers(ch, 1 TSRMLS_CC); in PHP_FUNCTION()
2347 _php_curl_cleanup_handle(ch); in PHP_FUNCTION()
2349 error = curl_easy_perform(ch->cp); in PHP_FUNCTION()
2350 SAVE_CURL_ERROR(ch, error); in PHP_FUNCTION()
2353 if (ch->handlers->write->buf.len > 0) { in PHP_FUNCTION()
2354 smart_str_free(&ch->handlers->write->buf); in PHP_FUNCTION()
2359 if (ch->handlers->std_err) { in PHP_FUNCTION()
2361 …stream = (php_stream*)zend_fetch_resource(&ch->handlers->std_err TSRMLS_CC, -1, NULL, NULL, 2, php… in PHP_FUNCTION()
2367 if (ch->handlers->write->method == PHP_CURL_RETURN && ch->handlers->write->buf.len > 0) { in PHP_FUNCTION()
2368 smart_str_0(&ch->handlers->write->buf); in PHP_FUNCTION()
2369 RETURN_STRINGL(ch->handlers->write->buf.c, ch->handlers->write->buf.len, 1); in PHP_FUNCTION()
2373 if (ch->handlers->write->method == PHP_CURL_FILE && ch->handlers->write->fp) { in PHP_FUNCTION()
2374 fflush(ch->handlers->write->fp); in PHP_FUNCTION()
2376 if (ch->handlers->write_header->method == PHP_CURL_FILE && ch->handlers->write_header->fp) { in PHP_FUNCTION()
2377 fflush(ch->handlers->write_header->fp); in PHP_FUNCTION()
2380 if (ch->handlers->write->method == PHP_CURL_RETURN) { in PHP_FUNCTION()
2393 php_curl *ch; in PHP_FUNCTION() local
2400 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2413 if (curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_URL, &s_code) == CURLE_OK) { in PHP_FUNCTION()
2416 if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_TYPE, &s_code) == CURLE_OK) { in PHP_FUNCTION()
2426 if (curl_easy_getinfo(ch->cp, CURLINFO_HTTP_CODE, &l_code) == CURLE_OK) { in PHP_FUNCTION()
2429 if (curl_easy_getinfo(ch->cp, CURLINFO_HEADER_SIZE, &l_code) == CURLE_OK) { in PHP_FUNCTION()
2432 if (curl_easy_getinfo(ch->cp, CURLINFO_REQUEST_SIZE, &l_code) == CURLE_OK) { in PHP_FUNCTION()
2435 if (curl_easy_getinfo(ch->cp, CURLINFO_FILETIME, &l_code) == CURLE_OK) { in PHP_FUNCTION()
2438 if (curl_easy_getinfo(ch->cp, CURLINFO_SSL_VERIFYRESULT, &l_code) == CURLE_OK) { in PHP_FUNCTION()
2441 if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_COUNT, &l_code) == CURLE_OK) { in PHP_FUNCTION()
2444 if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2447 if (curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2450 if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2453 if (curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2456 if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_UPLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2459 if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2462 if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2465 if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_UPLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2468 if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2471 if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2474 if (curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2477 if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) { in PHP_FUNCTION()
2481 if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) { in PHP_FUNCTION()
2489 if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) { in PHP_FUNCTION()
2494 if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_PORT, &l_code) == CURLE_OK) { in PHP_FUNCTION()
2497 if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_IP, &s_code) == CURLE_OK) { in PHP_FUNCTION()
2500 if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_PORT, &l_code) == CURLE_OK) { in PHP_FUNCTION()
2505 if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) { in PHP_FUNCTION()
2509 if (ch->header.str_len > 0) { in PHP_FUNCTION()
2510 CAAS("request_header", ch->header.str); in PHP_FUNCTION()
2530 if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) { in PHP_FUNCTION()
2550 if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) { in PHP_FUNCTION()
2572 if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) { in PHP_FUNCTION()
2580 if (ch->header.str_len > 0) { in PHP_FUNCTION()
2581 RETURN_STRINGL(ch->header.str, ch->header.str_len, 1); in PHP_FUNCTION()
2591 if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) { in PHP_FUNCTION()
2609 php_curl *ch; in PHP_FUNCTION() local
2615 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2617 ch->err.str[CURL_ERROR_SIZE] = 0; in PHP_FUNCTION()
2618 RETURN_STRING(ch->err.str, 1); in PHP_FUNCTION()
2627 php_curl *ch; in PHP_FUNCTION() local
2633 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2635 RETURN_LONG(ch->err.no); in PHP_FUNCTION()
2644 php_curl *ch; in PHP_FUNCTION() local
2650 ZEND_FETCH_RESOURCE(ch, php_curl *, &zid, -1, le_curl_name, le_curl); in PHP_FUNCTION()
2652 if (ch->in_callback) { in PHP_FUNCTION()
2657 if (ch->uses) { in PHP_FUNCTION()
2658 ch->uses--; in PHP_FUNCTION()
2667 static void _php_curl_close_ex(php_curl *ch TSRMLS_DC) in _php_curl_close_ex()
2670 fprintf(stderr, "DTOR CALLED, ch = %x\n", ch); in _php_curl_close_ex()
2673 _php_curl_verify_handlers(ch, 0 TSRMLS_CC); in _php_curl_close_ex()
2686 curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_nothing); in _php_curl_close_ex()
2687 curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write_nothing); in _php_curl_close_ex()
2689 curl_easy_cleanup(ch->cp); in _php_curl_close_ex()
2692 if (Z_REFCOUNT_P(ch->clone) <= 1) { in _php_curl_close_ex()
2693 zend_llist_clean(&ch->to_free->str); in _php_curl_close_ex()
2694 zend_llist_clean(&ch->to_free->post); in _php_curl_close_ex()
2695 zend_hash_destroy(ch->to_free->slist); in _php_curl_close_ex()
2696 efree(ch->to_free->slist); in _php_curl_close_ex()
2697 efree(ch->to_free); in _php_curl_close_ex()
2698 FREE_ZVAL(ch->clone); in _php_curl_close_ex()
2700 Z_DELREF_P(ch->clone); in _php_curl_close_ex()
2703 if (ch->handlers->write->buf.len > 0) { in _php_curl_close_ex()
2704 smart_str_free(&ch->handlers->write->buf); in _php_curl_close_ex()
2706 if (ch->handlers->write->func_name) { in _php_curl_close_ex()
2707 zval_ptr_dtor(&ch->handlers->write->func_name); in _php_curl_close_ex()
2709 if (ch->handlers->read->func_name) { in _php_curl_close_ex()
2710 zval_ptr_dtor(&ch->handlers->read->func_name); in _php_curl_close_ex()
2712 if (ch->handlers->write_header->func_name) { in _php_curl_close_ex()
2713 zval_ptr_dtor(&ch->handlers->write_header->func_name); in _php_curl_close_ex()
2715 if (ch->handlers->progress->func_name) { in _php_curl_close_ex()
2716 zval_ptr_dtor(&ch->handlers->progress->func_name); in _php_curl_close_ex()
2718 if (ch->handlers->passwd) { in _php_curl_close_ex()
2719 zval_ptr_dtor(&ch->handlers->passwd); in _php_curl_close_ex()
2721 if (ch->handlers->std_err) { in _php_curl_close_ex()
2722 zval_ptr_dtor(&ch->handlers->std_err); in _php_curl_close_ex()
2724 if (ch->header.str_len > 0) { in _php_curl_close_ex()
2725 efree(ch->header.str); in _php_curl_close_ex()
2728 if (ch->handlers->write_header->stream) { in _php_curl_close_ex()
2729 zval_ptr_dtor(&ch->handlers->write_header->stream); in _php_curl_close_ex()
2731 if (ch->handlers->write->stream) { in _php_curl_close_ex()
2732 zval_ptr_dtor(&ch->handlers->write->stream); in _php_curl_close_ex()
2734 if (ch->handlers->read->stream) { in _php_curl_close_ex()
2735 zval_ptr_dtor(&ch->handlers->read->stream); in _php_curl_close_ex()
2738 efree(ch->handlers->write); in _php_curl_close_ex()
2739 efree(ch->handlers->write_header); in _php_curl_close_ex()
2740 efree(ch->handlers->read); in _php_curl_close_ex()
2741 efree(ch->handlers->progress); in _php_curl_close_ex()
2742 efree(ch->handlers); in _php_curl_close_ex()
2743 efree(ch); in _php_curl_close_ex()
2751 php_curl *ch = (php_curl *) rsrc->ptr; in _php_curl_close() local
2752 _php_curl_close_ex(ch TSRMLS_CC); in _php_curl_close()