mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-06 05:47:13 +02:00
add header 'Accept: */*' similar to what GNU wget and curl does. This is needed for sites like https://netfilter.org Discovered in https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/61665 fixes: https://gitlab.alpinelinux.org/alpine/aports/-/issues/15861 ref: https://bugs.busybox.net/show_bug.cgi?id=15982 ref: http://lists.busybox.net/pipermail/busybox/2024-March/090661.html
76 lines
3.0 KiB
Diff
76 lines
3.0 KiB
Diff
From fd46eb7e14fa6891a9e767409a7f9dab4f2c0dfb Mon Sep 17 00:00:00 2001
|
|
From: Natanael Copa <ncopa@alpinelinux.org>
|
|
Date: Mon, 11 Mar 2024 12:47:15 +0100
|
|
Subject: [PATCH] wget: add header Accept: */*
|
|
|
|
Some servers (like https://netfilter.org) returns failure if the Accept
|
|
header is missing. Both GNU wget and curl adds this header, so make
|
|
busybox do the same.
|
|
|
|
fixes: https://bugs.busybox.net/show_bug.cgi?id=15982
|
|
|
|
function old new delta
|
|
wget_main 3120 3144 +24
|
|
.rodata 79296 79310 +14
|
|
wget_user_headers 76 84 +8
|
|
------------------------------------------------------------------------------
|
|
(add/remove: 0/0 grow/shrink: 3/0 up/down: 46/0) Total: 46 bytes
|
|
text data bss dec hex filename
|
|
825278 14260 2008 841546 cd74a busybox_old
|
|
825324 14260 2008 841592 cd778 busybox_unstripped
|
|
---
|
|
networking/wget.c | 10 ++++++++--
|
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/networking/wget.c b/networking/wget.c
|
|
index 199ddd4da..48486fdee 100644
|
|
--- a/networking/wget.c
|
|
+++ b/networking/wget.c
|
|
@@ -212,14 +212,16 @@ enum {
|
|
HDR_USER_AGENT = (1<<1),
|
|
HDR_RANGE = (1<<2),
|
|
HDR_CONTENT_TYPE = (1<<3),
|
|
- HDR_AUTH = (1<<4) * ENABLE_FEATURE_WGET_AUTHENTICATION,
|
|
- HDR_PROXY_AUTH = (1<<5) * ENABLE_FEATURE_WGET_AUTHENTICATION,
|
|
+ HDR_ACCEPT = (1<<4),
|
|
+ HDR_AUTH = (1<<5) * ENABLE_FEATURE_WGET_AUTHENTICATION,
|
|
+ HDR_PROXY_AUTH = (1<<6) * ENABLE_FEATURE_WGET_AUTHENTICATION,
|
|
};
|
|
static const char wget_user_headers[] ALIGN1 =
|
|
"Host:\0"
|
|
"User-Agent:\0"
|
|
"Range:\0"
|
|
"Content-Type:\0"
|
|
+ "Accept:\0"
|
|
# if ENABLE_FEATURE_WGET_AUTHENTICATION
|
|
"Authorization:\0"
|
|
"Proxy-Authorization:\0"
|
|
@@ -229,6 +231,7 @@ static const char wget_user_headers[] ALIGN1 =
|
|
# define USR_HEADER_USER_AGENT (G.user_headers & HDR_USER_AGENT)
|
|
# define USR_HEADER_RANGE (G.user_headers & HDR_RANGE)
|
|
# define USR_HEADER_CONTENT_TYPE (G.user_headers & HDR_CONTENT_TYPE)
|
|
+# define USR_HEADER_ACCEPT (G.user_headers & HDR_ACCEPT)
|
|
# define USR_HEADER_AUTH (G.user_headers & HDR_AUTH)
|
|
# define USR_HEADER_PROXY_AUTH (G.user_headers & HDR_PROXY_AUTH)
|
|
#else /* No long options, no user-headers :( */
|
|
@@ -236,6 +239,7 @@ static const char wget_user_headers[] ALIGN1 =
|
|
# define USR_HEADER_USER_AGENT 0
|
|
# define USR_HEADER_RANGE 0
|
|
# define USR_HEADER_CONTENT_TYPE 0
|
|
+# define USR_HEADER_ACCEPT 0
|
|
# define USR_HEADER_AUTH 0
|
|
# define USR_HEADER_PROXY_AUTH 0
|
|
#endif
|
|
@@ -1232,6 +1236,8 @@ static void download_one_url(const char *url)
|
|
SENDFMT(sfp, "Host: %s\r\n", target.host);
|
|
if (!USR_HEADER_USER_AGENT)
|
|
SENDFMT(sfp, "User-Agent: %s\r\n", G.user_agent);
|
|
+ if (!USR_HEADER_ACCEPT)
|
|
+ SENDFMT(sfp, "Accept: */*\r\n");
|
|
|
|
/* Ask server to close the connection as soon as we are done
|
|
* (IOW: we do not intend to send more requests)
|
|
--
|
|
2.44.0
|
|
|