if (msg && CURLMSG_DONE == msg->msg) {
if (CURLE_OK != msg->data.result) {
php_http_curle_storage_t *st = php_http_curle_get_storage(msg->easy_handle);
- php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT, "%s; %s (%s)", curl_easy_strerror(msg->data.result), STR_PTR(st->errorbuffer), STR_PTR(st->url));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s; %s (%s)", curl_easy_strerror(msg->data.result), STR_PTR(st->errorbuffer), STR_PTR(st->url));
}
if ((enqueue = php_http_client_enqueued(context, msg->easy_handle, compare_queue))) {
while (CURLM_CALL_MULTI_PERFORM == (rc = curl_multi_socket_action(curl->handle, CURL_SOCKET_TIMEOUT, 0, &curl->unfinished)));
if (CURLM_OK != rc) {
- php_http_error(HE_WARNING, PHP_HTTP_E_SOCKET, "%s", curl_multi_strerror(rc));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", curl_multi_strerror(rc));
}
php_http_curlm_responsehandler(context);
fprintf(stderr, "E");
#endif
if (curl->useevents) {
- CURLMcode rc = CURLE_OK;
+ CURLMcode rc = CURLM_OK;
TSRMLS_FETCH_FROM_CTX(context->ts);
while (CURLM_CALL_MULTI_PERFORM == (rc = curl_multi_socket_action(curl->handle, socket, etoca(action), &curl->unfinished)));
if (CURLM_OK != rc) {
- php_http_error(HE_WARNING, PHP_HTTP_E_SOCKET, "%s", curl_multi_strerror(rc));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", curl_multi_strerror(rc));
}
php_http_curlm_responsehandler(context);
return 0;
default:
- php_http_error(HE_WARNING, PHP_HTTP_E_SOCKET, "Unknown socket action %d", action);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown socket action %d", action);
return -1;
}
break;
}
if (rv != SUCCESS) {
- php_http_error(HE_NOTICE, PHP_HTTP_E_CLIENT, "Could not set option %s", opt->name.s);
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Could not set option %s", opt->name.s);
}
return rv;
}
TSRMLS_FETCH_FROM_CTX(h->ts);
if (!(handle = php_resource_factory_handle_ctor(rf, NULL TSRMLS_CC))) {
- php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT, "Failed to initialize curl handle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to initialize curl handle");
return NULL;
}
/* request url */
if (!PHP_HTTP_INFO(msg).request.url) {
- php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT, "Cannot request empty URL");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot request empty URL");
return FAILURE;
}
storage->errorbuffer[0] = '\0';
if (PHP_HTTP_INFO(msg).request.method) {
curl_easy_setopt(curl->handle, CURLOPT_CUSTOMREQUEST, PHP_HTTP_INFO(msg).request.method);
} else {
- php_http_error(HE_WARNING, PHP_HTTP_E_REQUEST_METHOD, "Cannot use empty request method");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot use empty request method");
return FAILURE;
}
break;
TSRMLS_FETCH_FROM_CTX(h->ts);
if (!handle && !(handle = php_resource_factory_handle_ctor(h->rf, NULL TSRMLS_CC))) {
- php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_POOL, "Failed to initialize curl handle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to initialize curl handle");
return NULL;
}
php_url *purl;
php_resource_factory_t *rf = NULL;
- if ((purl = php_url_parse(url))) {
+ if (!url || !*url) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot request empty URL");
+ return NULL;
+ }
+
+ purl = php_url_parse(url);
+
+ if (!purl) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not parse URL '%s'", url);
+ return NULL;
+ } else {
char *id_str = NULL;
size_t id_len = spprintf(&id_str, 0, "%s:%d", STR_PTR(purl->host), purl->port ? purl->port : 80);
php_persistent_handle_factory_t *pf = php_persistent_handle_concede(NULL, ZEND_STRL("http\\Client\\Curl\\Request"), id_str, id_len, NULL, NULL TSRMLS_CC);
php_http_client_curl_t *curl = h->ctx;
php_http_client_curl_handler_t *handler;
php_http_client_progress_state_t *progress;
+ php_resource_factory_t *rf;
TSRMLS_FETCH_FROM_CTX(h->ts);
- handler = php_http_client_curl_handler_init(h, create_rf(enqueue->request->http.info.request.url TSRMLS_CC));
+ rf = create_rf(enqueue->request->http.info.request.url TSRMLS_CC);
+ if (!rf) {
+ return FAILURE;
+ }
+
+ handler = php_http_client_curl_handler_init(h, rf);
if (!handler) {
return FAILURE;
}
return SUCCESS;
} else {
- php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT_POOL, "Could not enqueue request: %s", curl_multi_strerror(rs));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not enqueue request: %s", curl_multi_strerror(rs));
return FAILURE;
}
}
zend_llist_del_element(&h->requests, handler->handle, (int (*)(void *, void *)) compare_queue);
return SUCCESS;
} else {
- php_http_error(HE_WARNING, PHP_HTTP_E_CLIENT, "Could not dequeue request: %s", curl_multi_strerror(rs));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not dequeue request: %s", curl_multi_strerror(rs));
}
return FAILURE;
if (curl->useevents) {
TSRMLS_FETCH_FROM_CTX(h->ts);
- php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "not implemented");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "not implemented");
return FAILURE;
}
#endif
#if PHP_HTTP_HAVE_EVENT
if (curl->useevents) {
TSRMLS_FETCH_FROM_CTX(h->ts);
- php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "not implemented");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "not implemented");
return FAILURE;
}
#endif
#endif
if (ev_rc < 0) {
- php_http_error(HE_ERROR, PHP_HTTP_E_RUNTIME, "Error in event_base_dispatch()");
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error in event_base_dispatch()");
return FAILURE;
}
} while (curl->unfinished);
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_http_error(HE_WARNING, PHP_HTTP_E_SOCKET, "WinSock error: %d", WSAGetLastError());
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "WinSock error: %d", WSAGetLastError());
#else
- php_http_error(HE_WARNING, PHP_HTTP_E_SOCKET, strerror(errno));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, strerror(errno));
#endif
return FAILURE;
}
php_http_client_curl_getopt
};
-PHP_HTTP_API php_http_client_ops_t *php_http_client_curl_get_ops(void)
+php_http_client_ops_t *php_http_client_curl_get_ops(void)
{
return &php_http_client_curl_ops;
}