mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[curl] Display curl error
This commit is contained in:
parent
62c42d41e3
commit
df4a2bedbf
@ -4,6 +4,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIBCURL
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
@ -158,6 +162,12 @@ get_state_message(struct connection_state state, struct terminal *term)
|
|||||||
int len;
|
int len;
|
||||||
char *unknown_error = _("Unknown error", term);
|
char *unknown_error = _("Unknown error", term);
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIBCURL
|
||||||
|
if (state.basic < S_CURL_ERROR) {
|
||||||
|
return (char *)curl_easy_strerror(S_CURL_ERROR - state.basic);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!is_system_error(state)) {
|
if (!is_system_error(state)) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -114,6 +114,8 @@ enum connection_basic_state {
|
|||||||
S_BITTORRENT_PEER_URL = -100804,
|
S_BITTORRENT_PEER_URL = -100804,
|
||||||
|
|
||||||
S_FSP_OPEN_SESSION_UNKN = -100900,
|
S_FSP_OPEN_SESSION_UNKN = -100900,
|
||||||
|
|
||||||
|
S_CURL_ERROR = -101000,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int connection_basic_state_T;
|
typedef int connection_basic_state_T;
|
||||||
|
@ -616,24 +616,22 @@ check_multi_info(GlobalInfo *g)
|
|||||||
res = msg->data.result;
|
res = msg->data.result;
|
||||||
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
|
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
|
||||||
|
|
||||||
if (res == CURLE_REMOTE_FILE_NOT_FOUND || res == CURLE_SSH) {
|
if (conn->uri->protocol == PROTOCOL_HTTP || conn->uri->protocol == PROTOCOL_HTTPS) {
|
||||||
ftp = (struct ftpes_connection_info *)conn->info;
|
http_curl_handle_error(conn, res);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (ftp && !ftp->dir) {
|
if (conn->uri->protocol == PROTOCOL_FTP || conn->uri->protocol == PROTOCOL_FTPES || conn->uri->protocol == PROTOCOL_SFTP) {
|
||||||
retry_connection(conn, connection_state(S_RESTART));
|
if (res == CURLE_REMOTE_FILE_NOT_FOUND || res == CURLE_SSH) {
|
||||||
} else {
|
ftp = (struct ftpes_connection_info *)conn->info;
|
||||||
abort_connection(conn, connection_state(S_OK));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (conn->uri->protocol == PROTOCOL_HTTP || conn->uri->protocol == PROTOCOL_HTTPS) {
|
|
||||||
char *url = http_curl_check_redirect(conn);
|
|
||||||
|
|
||||||
if (url) {
|
if (ftp && !ftp->dir) {
|
||||||
redirect_cache(conn->cached, url, 0, 0);
|
retry_connection(conn, connection_state(S_RESTART));
|
||||||
|
} else {
|
||||||
abort_connection(conn, connection_state(S_OK));
|
abort_connection(conn, connection_state(S_OK));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
abort_connection(conn, connection_state(S_OK));
|
abort_connection(conn, connection_state(S_OK));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ http_got_data(void *stream, void *buf, size_t len)
|
|||||||
abort_connection(conn, connection_state(S_OK));
|
abort_connection(conn, connection_state(S_OK));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
http_curl_check_redirect(struct connection *conn)
|
http_curl_check_redirect(struct connection *conn)
|
||||||
{
|
{
|
||||||
struct http_curl_connection_info *http;
|
struct http_curl_connection_info *http;
|
||||||
@ -383,6 +383,24 @@ http_curl_check_redirect(struct connection *conn)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
http_curl_handle_error(struct connection *conn, CURLcode res)
|
||||||
|
{
|
||||||
|
if (res == CURLE_OK) {
|
||||||
|
char *url = http_curl_check_redirect(conn);
|
||||||
|
|
||||||
|
if (url) {
|
||||||
|
redirect_cache(conn->cached, url, 0, 0);
|
||||||
|
abort_connection(conn, connection_state(S_OK));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
abort_connection(conn, connection_state(S_OK));
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
abort_connection(conn, connection_state(S_CURL_ERROR - res));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
http_curl_protocol_handler(struct connection *conn)
|
http_curl_protocol_handler(struct connection *conn)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef EL__PROTOCOL_CURL_HTTP_H
|
#ifndef EL__PROTOCOL_CURL_HTTP_H
|
||||||
#define EL__PROTOCOL_CURL_HTTP_H
|
#define EL__PROTOCOL_CURL_HTTP_H
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include "main/module.h"
|
#include "main/module.h"
|
||||||
#include "protocol/protocol.h"
|
#include "protocol/protocol.h"
|
||||||
|
|
||||||
@ -13,7 +15,7 @@ struct connection;
|
|||||||
|
|
||||||
extern protocol_handler_T http_curl_protocol_handler;
|
extern protocol_handler_T http_curl_protocol_handler;
|
||||||
|
|
||||||
char *http_curl_check_redirect(struct connection *conn);
|
void http_curl_handle_error(struct connection *conn, CURLcode res);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user