summaryrefslogtreecommitdiff
path: root/main/busybox/0001-wget-add-header-Accept.patch
blob: 20d8d3a65a44d9cb50f0d7e82897a39a7f2c0b60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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