aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2024-12-10 19:49:31 +0100
committerRodrigo Arias Mallo <rodarima@gmail.com>2024-12-11 21:37:06 +0100
commit07dd1aba3284761c20d9c87a81967c84c8a98cf2 (patch)
treef0a30222b5ef51b91b40fa2e073b37a3dbd0584e
parente40ea3913a9501a3d62b944bbb7d49ba1052f52e (diff)
Use Dillo user agent for downloads too
Send the user agent to the downloads DPI so we can use the same as Dillo uses from the http_user_agent option. See: https://lists.mailman3.com/hyperkitty/list/dillo-dev@mailman3.com/thread/A6IHJ4TBGHJ3CT2UOMEAROSG2WRTRO6U/
-rw-r--r--dpi/downloads.cc19
-rw-r--r--src/capi.c8
2 files changed, 16 insertions, 11 deletions
diff --git a/dpi/downloads.cc b/dpi/downloads.cc
index ee805de9..69e04f8f 100644
--- a/dpi/downloads.cc
+++ b/dpi/downloads.cc
@@ -120,7 +120,7 @@ class DLItem {
Fl_Widget *prTitle, *prGot, *prSize, *prRate, *pr_Rate, *prETA, *prETAt;
public:
- DLItem(const char *full_filename, const char *url);
+ DLItem(const char *full_filename, const char *url, const char *user_agent);
~DLItem();
void child_init();
void father_init();
@@ -174,7 +174,7 @@ class DLWin {
public:
DLWin(int ww, int wh);
- void add(const char *full_filename, const char *url);
+ void add(const char *full_filename, const char *url, const char *user_agent);
void del(int n_item);
int num();
int num_running();
@@ -284,7 +284,7 @@ static void prButton_scb(Fl_Widget *, void *cb_data)
i->prButton_cb();
}
-DLItem::DLItem(const char *full_filename, const char *url)
+DLItem::DLItem(const char *full_filename, const char *url, const char *user_agent)
{
struct stat ss;
const char *p;
@@ -324,7 +324,6 @@ DLItem::DLItem(const char *full_filename, const char *url)
cookies_path = dStrconcat(dGethomedir(), "/.dillo/cookies.txt", NULL);
dl_argv = new char*[10];
int i = 0;
- const char *user_agent = "Dillo/" VERSION;
dl_argv[i++] = (char*)"wget";
if (stat(fullname, &ss) == 0)
init_bytesize = (int)ss.st_size;
@@ -844,7 +843,7 @@ static void read_req_cb(int req_fd, void *)
int sock_fd;
socklen_t csz;
Dsh *sh = NULL;
- char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *dl_dest = NULL;
+ char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *dl_dest = NULL, *ua = NULL;
/* Initialize the value-result parameter */
csz = sizeof(struct sockaddr_un);
@@ -898,7 +897,11 @@ static void read_req_cb(int req_fd, void *)
MSG("Failed to parse 'destination' in {%s}\n", dpip_tag);
goto end;
}
- dl_win->add(dl_dest, url);
+ if (!(ua = a_Dpip_get_attr(dpip_tag, "user-agent"))){
+ MSG("Failed to parse 'user-agent' in {%s}\n", dpip_tag);
+ goto end;
+ }
+ dl_win->add(dl_dest, url, ua);
end:
dFree(cmd);
@@ -931,9 +934,9 @@ static void dlwin_esc_cb(Fl_Widget *, void *)
* Add a new download request to the main window and
* fork a child to do the job.
*/
-void DLWin::add(const char *full_filename, const char *url)
+void DLWin::add(const char *full_filename, const char *url, const char *user_agent)
{
- DLItem *dl_item = new DLItem(full_filename, url);
+ DLItem *dl_item = new DLItem(full_filename, url, user_agent);
mDList->add(dl_item);
mPG->insert(*dl_item->get_widget(), 0);
diff --git a/src/capi.c b/src/capi.c
index fb992fe4..0e6ef82e 100644
--- a/src/capi.c
+++ b/src/capi.c
@@ -2,7 +2,7 @@
* File: capi.c
*
* Copyright 2002-2007 Jorge Arellano Cid <jcid@dillo.org>
- * Copyright 2023 Rodrigo Arias Mallo <rodarima@gmail.com>
+ * Copyright 2023-2024 Rodrigo Arias Mallo <rodarima@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@
#include "uicmd.hh"
#include "domain.h"
#include "../dpip/dpip.h"
+#include "prefs.h"
/* for testing dpi chat */
#include "bookmark.h"
@@ -305,8 +306,9 @@ static char *Capi_dpi_build_cmd(DilloWeb *web, char *server)
if (strcmp(server, "downloads") == 0) {
/* let the downloads server get it */
- cmd = a_Dpip_build_cmd("cmd=%s url=%s destination=%s",
- "download", URL_STR(web->url), web->filename);
+ cmd = a_Dpip_build_cmd("cmd=%s url=%s destination=%s user-agent=%s",
+ "download", URL_STR(web->url), web->filename,
+ prefs.http_user_agent);
} else {
/* For everyone else, the url string is enough... */