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"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LIBCURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
@ -158,6 +162,12 @@ get_state_message(struct connection_state state, struct terminal *term)
|
||||
int len;
|
||||
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)) {
|
||||
int i;
|
||||
|
||||
|
@ -114,6 +114,8 @@ enum connection_basic_state {
|
||||
S_BITTORRENT_PEER_URL = -100804,
|
||||
|
||||
S_FSP_OPEN_SESSION_UNKN = -100900,
|
||||
|
||||
S_CURL_ERROR = -101000,
|
||||
};
|
||||
|
||||
typedef int connection_basic_state_T;
|
||||
|
@ -616,6 +616,12 @@ check_multi_info(GlobalInfo *g)
|
||||
res = msg->data.result;
|
||||
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
|
||||
|
||||
if (conn->uri->protocol == PROTOCOL_HTTP || conn->uri->protocol == PROTOCOL_HTTPS) {
|
||||
http_curl_handle_error(conn, res);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (conn->uri->protocol == PROTOCOL_FTP || conn->uri->protocol == PROTOCOL_FTPES || conn->uri->protocol == PROTOCOL_SFTP) {
|
||||
if (res == CURLE_REMOTE_FILE_NOT_FOUND || res == CURLE_SSH) {
|
||||
ftp = (struct ftpes_connection_info *)conn->info;
|
||||
|
||||
@ -624,16 +630,8 @@ check_multi_info(GlobalInfo *g)
|
||||
} else {
|
||||
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) {
|
||||
redirect_cache(conn->cached, url, 0, 0);
|
||||
abort_connection(conn, connection_state(S_OK));
|
||||
return;
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
char *
|
||||
static char *
|
||||
http_curl_check_redirect(struct connection *conn)
|
||||
{
|
||||
struct http_curl_connection_info *http;
|
||||
@ -383,6 +383,24 @@ http_curl_check_redirect(struct connection *conn)
|
||||
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
|
||||
http_curl_protocol_handler(struct connection *conn)
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef EL__PROTOCOL_CURL_HTTP_H
|
||||
#define EL__PROTOCOL_CURL_HTTP_H
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "main/module.h"
|
||||
#include "protocol/protocol.h"
|
||||
|
||||
@ -13,7 +15,7 @@ struct connection;
|
||||
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user