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" Signed-off-by: Ildar Shaimordanov <[email protected]> --- networking/wget.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/networking/wget.c b/networking/wget.c index 91ef99eab..789979c1a 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -213,6 +213,7 @@ enum { 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<<5), }; static const char wget_user_headers[] ALIGN1 = "Host:\0" @@ -222,18 +223,21 @@ static const char wget_user_headers[] ALIGN1 = "Authorization:\0" "Proxy-Authorization:\0" # endif + "Content-Type:\0" ; # 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_CONTENT_TYPE (G.user_headers & HDR_CONTENT_TYPE) #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_CONTENT_TYPE 0 #endif /* Globals */ @@ -1261,8 +1265,13 @@ static void download_one_url(const char *url) } if (G.post_data) { + /* Don't overwrite the user-specified header */ + 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", -- 2.28.0
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
