X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=src%2Fphp_http_client_curl.c;h=b7c6b05389012f74bc667b2d2a38f23feee855b9;hp=18d75d739f2ff2b86a6d86628bde0ed59eb9e2bf;hb=refs%2Fheads%2Fv2.6.x;hpb=1ac722a1169ffe0f804f8d30a79c2f270d0d7999 diff --git a/src/php_http_client_curl.c b/src/php_http_client_curl.c index 18d75d7..b7c6b05 100644 --- a/src/php_http_client_curl.c +++ b/src/php_http_client_curl.c @@ -182,22 +182,19 @@ static int php_http_curle_progress_callback(void *ctx, double dltotal, double dl #endif { php_http_client_curl_handler_t *h = ctx; - zend_bool update = 0; if (h->progress.dl.total != dltotal || h->progress.dl.now != dlnow || h->progress.ul.total != ultotal || h->progress.ul.now != ulnow ) { - update = 1; - h->progress.dl.total = dltotal; h->progress.dl.now = dlnow; h->progress.ul.total = ultotal; h->progress.ul.now = ulnow; } - if (update && h->client->callback.progress.func) { + if (h->client->callback.progress.func) { h->client->callback.progress.func(h->client->callback.progress.arg, h->client, &h->queue, &h->progress); } @@ -453,6 +450,11 @@ static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info) add_assoc_long_ex(&array, "local_port", sizeof("local_port"), l); } #endif +#if PHP_HTTP_CURL_VERSION(7,50,0) + if (CURLE_OK == curl_easy_getinfo(ch, CURLINFO_HTTP_VERSION, &l)) { + add_assoc_long_ex(&array, "http_version", sizeof("http_version"), l); + } +#endif /* END::CURLINFO */ @@ -2168,6 +2170,11 @@ static ZEND_RESULT_CODE php_http_client_curl_dequeue(php_http_client_t *h, php_h php_http_client_curl_handler_t *handler = enqueue->opaque; TSRMLS_FETCH_FROM_CTX(h->ts); + if (h->callback.depth) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not dequeue request while executing callbacks"); + return FAILURE; + } + php_http_client_curl_handler_clear(handler); if (CURLM_OK == (rs = curl_multi_remove_handle(curl->handle->multi, handler->handle))) { zend_llist_del_element(&h->requests, handler->handle, (int (*)(void *, void *)) compare_queue); @@ -2231,16 +2238,17 @@ static int php_http_client_curl_once(php_http_client_t *h) { php_http_client_curl_t *curl = h->ctx; - if (curl->ev_ops) { - curl->ev_ops->once(curl->ev_ctx); - } else { - while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curl->handle->multi, &curl->unfinished)); - } + if (!h->callback.depth) { + if (curl->ev_ops) { + curl->ev_ops->once(curl->ev_ctx); + } else { + while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(curl->handle->multi, &curl->unfinished)); + } - php_http_client_curl_responsehandler(h); + php_http_client_curl_responsehandler(h); + } return curl->unfinished; - } static ZEND_RESULT_CODE php_http_client_curl_exec(php_http_client_t *h) @@ -2248,19 +2256,21 @@ static ZEND_RESULT_CODE php_http_client_curl_exec(php_http_client_t *h) php_http_client_curl_t *curl = h->ctx; TSRMLS_FETCH_FROM_CTX(h->ts); - if (curl->ev_ops) { - return curl->ev_ops->exec(curl->ev_ctx); - } + if (!h->callback.depth) { + if (curl->ev_ops) { + return curl->ev_ops->exec(curl->ev_ctx); + } - while (php_http_client_curl_once(h) && !EG(exception)) { - if (SUCCESS != php_http_client_curl_wait(h, NULL)) { + while (php_http_client_curl_once(h) && !EG(exception)) { + if (SUCCESS != php_http_client_curl_wait(h, NULL)) { #ifdef PHP_WIN32 - /* see http://msdn.microsoft.com/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "WinSock error: %d", WSAGetLastError()); + /* see http://msdn.microsoft.com/library/en-us/winsock/winsock/windows_sockets_error_codes_2.asp */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "WinSock error: %d", WSAGetLastError()); #else php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno)); #endif - return FAILURE; + return FAILURE; + } } }