summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorIldar Shaimordanov2021-12-12 03:19:13 +0100
committerDenys Vlasenko2021-12-12 03:22:43 +0100
commitb9fba185c570b52fccffa2b9ae39ba32a0860daf (patch)
treed4105fca3fb86b3c4e0d6fe05bb7f31bb16dd49b /networking
parentc7b90dc4d10ccc4f95940f42676ff907cee73272 (diff)
downloadbusybox-b9fba185c570b52fccffa2b9ae39ba32a0860daf.zip
busybox-b9fba185c570b52fccffa2b9ae39ba32a0860daf.tar.gz
wget: allow end-users to customize Content-Type for --post-data and --post-file
More explanation in this PR: https://github.com/rmyorston/busybox-w32/pull/233 The real use-case: wget https://api.github.com/markdown/raw --header "Content-Type: text/plain" function old new delta wget_main 2560 2581 +21 wget_user_headers 62 76 +14 .rodata 104196 104197 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 36/0) Total: 36 bytes Signed-off-by: Ildar Shaimordanov <ildar.shaimordanov@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/wget.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/networking/wget.c b/networking/wget.c
index 91ef99e..9ec0e67 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -211,29 +211,33 @@ enum {
HDR_HOST = (1<<0),
HDR_USER_AGENT = (1<<1),
HDR_RANGE = (1<<2),
- HDR_AUTH = (1<<3) * ENABLE_FEATURE_WGET_AUTHENTICATION,
- HDR_PROXY_AUTH = (1<<4) * ENABLE_FEATURE_WGET_AUTHENTICATION,
+ HDR_CONTENT_TYPE = (1<<3),
+ HDR_AUTH = (1<<4) * ENABLE_FEATURE_WGET_AUTHENTICATION,
+ HDR_PROXY_AUTH = (1<<5) * ENABLE_FEATURE_WGET_AUTHENTICATION,
};
static const char wget_user_headers[] ALIGN1 =
"Host:\0"
"User-Agent:\0"
"Range:\0"
+ "Content-Type:\0"
# if ENABLE_FEATURE_WGET_AUTHENTICATION
"Authorization:\0"
"Proxy-Authorization:\0"
# endif
;
-# define USR_HEADER_HOST (G.user_headers & HDR_HOST)
-# define USR_HEADER_USER_AGENT (G.user_headers & HDR_USER_AGENT)
-# define USR_HEADER_RANGE (G.user_headers & HDR_RANGE)
-# define USR_HEADER_AUTH (G.user_headers & HDR_AUTH)
-# define USR_HEADER_PROXY_AUTH (G.user_headers & HDR_PROXY_AUTH)
+# define USR_HEADER_HOST (G.user_headers & HDR_HOST)
+# 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_AUTH (G.user_headers & HDR_AUTH)
+# define USR_HEADER_PROXY_AUTH (G.user_headers & HDR_PROXY_AUTH)
#else /* No long options, no user-headers :( */
-# define USR_HEADER_HOST 0
-# define USR_HEADER_USER_AGENT 0
-# define USR_HEADER_RANGE 0
-# define USR_HEADER_AUTH 0
-# define USR_HEADER_PROXY_AUTH 0
+# define USR_HEADER_HOST 0
+# define USR_HEADER_USER_AGENT 0
+# define USR_HEADER_RANGE 0
+# define USR_HEADER_CONTENT_TYPE 0
+# define USR_HEADER_AUTH 0
+# define USR_HEADER_PROXY_AUTH 0
#endif
/* Globals */
@@ -1261,8 +1265,13 @@ static void download_one_url(const char *url)
}
if (G.post_data) {
+ /* If user did not override it... */
+ if (!USR_HEADER_CONTENT_TYPE) {
+ SENDFMT(sfp,
+ "Content-Type: application/x-www-form-urlencoded\r\n"
+ );
+ }
SENDFMT(sfp,
- "Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: %u\r\n"
"\r\n"
"%s",