1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[curl] Send username and password in http

This commit is contained in:
Witold Filipczyk 2023-07-01 09:07:22 +02:00
parent 008eacef69
commit 9389e2f903
2 changed files with 10 additions and 5 deletions

View File

@ -377,6 +377,8 @@ static void
do_ftpes(struct connection *conn) do_ftpes(struct connection *conn)
{ {
struct ftpes_connection_info *ftp = (struct ftpes_connection_info *)mem_calloc(1, sizeof(*ftp)); struct ftpes_connection_info *ftp = (struct ftpes_connection_info *)mem_calloc(1, sizeof(*ftp));
struct auth_entry *auth = find_auth(conn->uri);
char *url;
struct string u; struct string u;
CURL *curl; CURL *curl;
@ -392,10 +394,7 @@ do_ftpes(struct connection *conn)
} }
conn->from = 0; conn->from = 0;
conn->unrestartable = 1; conn->unrestartable = 1;
url = get_uri_string(conn->uri, URI_HOST | URI_PORT | URI_DATA);
/// FILE *stream = fopen("/tmp/curl.log", "a");
struct auth_entry *auth = find_auth(conn->uri);
char *url = get_uri_string(conn->uri, URI_HOST | URI_PORT | URI_DATA);
if (!url) { if (!url) {
abort_connection(conn, connection_state(S_OUT_OF_MEM)); abort_connection(conn, connection_state(S_OUT_OF_MEM));

View File

@ -130,6 +130,8 @@ static void
do_http(struct connection *conn) do_http(struct connection *conn)
{ {
struct http_curl_connection_info *http = (struct http_curl_connection_info *)mem_calloc(1, sizeof(*http)); struct http_curl_connection_info *http = (struct http_curl_connection_info *)mem_calloc(1, sizeof(*http));
struct auth_entry *auth = find_auth(conn->uri);
struct string u; struct string u;
CURL *curl; CURL *curl;
@ -175,7 +177,6 @@ do_http(struct connection *conn)
mem_free(url); mem_free(url);
curl = curl_easy_init(); curl = curl_easy_init();
if (curl) { if (curl) {
CURLMcode rc; CURLMcode rc;
char *optstr; char *optstr;
@ -194,6 +195,11 @@ do_http(struct connection *conn)
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""); curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
if (auth) {
curl_easy_setopt(curl, CURLOPT_USERNAME, auth->user);
curl_easy_setopt(curl, CURLOPT_PASSWORD, auth->password);
}
if (conn->uri->post) { if (conn->uri->post) {
char *postend = strchr(conn->uri->post, '\n'); char *postend = strchr(conn->uri->post, '\n');
char *post = postend ? postend + 1 : conn->uri->post; char *post = postend ? postend + 1 : conn->uri->post;