aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-07-26 15:13:43 +0100
committerRon Yorston <rmy@pobox.com>2024-07-26 15:13:43 +0100
commit2628ffaceabcfcd614f9b09db98da82e98fb048b (patch)
tree188e0f57477804b46acd4d2d0034262c75779ff3
parent2df01b247d5d14e462d9902459677efb7e10e9c0 (diff)
downloadbusybox-w32-2628ffaceabcfcd614f9b09db98da82e98fb048b.tar.gz
busybox-w32-2628ffaceabcfcd614f9b09db98da82e98fb048b.tar.bz2
busybox-w32-2628ffaceabcfcd614f9b09db98da82e98fb048b.zip
wget: let user override Content-Length
The wget applet allows several common headers to be overridden by the user. Add 'Content-Length' to the list. Adds 32-64 bytes. (GitHub issue #432)
-rw-r--r--networking/wget.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/networking/wget.c b/networking/wget.c
index b01304897..ae847044e 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -214,6 +214,9 @@ enum {
214 HDR_CONTENT_TYPE = (1<<3), 214 HDR_CONTENT_TYPE = (1<<3),
215 HDR_AUTH = (1<<4) * ENABLE_FEATURE_WGET_AUTHENTICATION, 215 HDR_AUTH = (1<<4) * ENABLE_FEATURE_WGET_AUTHENTICATION,
216 HDR_PROXY_AUTH = (1<<5) * ENABLE_FEATURE_WGET_AUTHENTICATION, 216 HDR_PROXY_AUTH = (1<<5) * ENABLE_FEATURE_WGET_AUTHENTICATION,
217# if ENABLE_PLATFORM_MINGW32
218 HDR_CONTENT_LENGTH = (1<<(4 + 2 * ENABLE_FEATURE_WGET_AUTHENTICATION)),
219# endif
217}; 220};
218static const char wget_user_headers[] ALIGN1 = 221static const char wget_user_headers[] ALIGN1 =
219 "Host:\0" 222 "Host:\0"
@@ -224,6 +227,9 @@ static const char wget_user_headers[] ALIGN1 =
224 "Authorization:\0" 227 "Authorization:\0"
225 "Proxy-Authorization:\0" 228 "Proxy-Authorization:\0"
226# endif 229# endif
230# if ENABLE_PLATFORM_MINGW32
231 "Content-Length:\0"
232# endif
227 ; 233 ;
228# define USR_HEADER_HOST (G.user_headers & HDR_HOST) 234# define USR_HEADER_HOST (G.user_headers & HDR_HOST)
229# define USR_HEADER_USER_AGENT (G.user_headers & HDR_USER_AGENT) 235# define USR_HEADER_USER_AGENT (G.user_headers & HDR_USER_AGENT)
@@ -231,6 +237,7 @@ static const char wget_user_headers[] ALIGN1 =
231# define USR_HEADER_CONTENT_TYPE (G.user_headers & HDR_CONTENT_TYPE) 237# define USR_HEADER_CONTENT_TYPE (G.user_headers & HDR_CONTENT_TYPE)
232# define USR_HEADER_AUTH (G.user_headers & HDR_AUTH) 238# define USR_HEADER_AUTH (G.user_headers & HDR_AUTH)
233# define USR_HEADER_PROXY_AUTH (G.user_headers & HDR_PROXY_AUTH) 239# define USR_HEADER_PROXY_AUTH (G.user_headers & HDR_PROXY_AUTH)
240# define USR_HEADER_CONTENT_LENGTH (G.user_headers & HDR_CONTENT_LENGTH)
234#else /* No long options, no user-headers :( */ 241#else /* No long options, no user-headers :( */
235# define USR_HEADER_HOST 0 242# define USR_HEADER_HOST 0
236# define USR_HEADER_USER_AGENT 0 243# define USR_HEADER_USER_AGENT 0
@@ -238,6 +245,7 @@ static const char wget_user_headers[] ALIGN1 =
238# define USR_HEADER_CONTENT_TYPE 0 245# define USR_HEADER_CONTENT_TYPE 0
239# define USR_HEADER_AUTH 0 246# define USR_HEADER_AUTH 0
240# define USR_HEADER_PROXY_AUTH 0 247# define USR_HEADER_PROXY_AUTH 0
248# define USR_HEADER_CONTENT_LENGTH 0
241#endif 249#endif
242 250
243/* Globals */ 251/* Globals */
@@ -1303,6 +1311,18 @@ static void download_one_url(const char *url)
1303 "Content-Type: application/x-www-form-urlencoded\r\n" 1311 "Content-Type: application/x-www-form-urlencoded\r\n"
1304 ); 1312 );
1305 } 1313 }
1314# if ENABLE_PLATFORM_MINGW32
1315 if (!USR_HEADER_CONTENT_LENGTH)
1316 SENDFMT(sfp, "Content-Length: %u\r\n",
1317 (int)strlen(G.post_data)
1318 );
1319 SENDFMT(sfp,
1320 "\r\n"
1321 "%s",
1322 G.post_data
1323 );
1324 } else
1325# else
1306 SENDFMT(sfp, 1326 SENDFMT(sfp,
1307 "Content-Length: %u\r\n" 1327 "Content-Length: %u\r\n"
1308 "\r\n" 1328 "\r\n"
@@ -1310,6 +1330,7 @@ static void download_one_url(const char *url)
1310 (int) strlen(G.post_data), G.post_data 1330 (int) strlen(G.post_data), G.post_data
1311 ); 1331 );
1312 } else 1332 } else
1333# endif
1313#endif 1334#endif
1314 { 1335 {
1315 SENDFMT(sfp, "\r\n"); 1336 SENDFMT(sfp, "\r\n");