From 2628ffaceabcfcd614f9b09db98da82e98fb048b Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 26 Jul 2024 15:13:43 +0100 Subject: 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) --- networking/wget.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 { HDR_CONTENT_TYPE = (1<<3), HDR_AUTH = (1<<4) * ENABLE_FEATURE_WGET_AUTHENTICATION, HDR_PROXY_AUTH = (1<<5) * ENABLE_FEATURE_WGET_AUTHENTICATION, +# if ENABLE_PLATFORM_MINGW32 + HDR_CONTENT_LENGTH = (1<<(4 + 2 * ENABLE_FEATURE_WGET_AUTHENTICATION)), +# endif }; static const char wget_user_headers[] ALIGN1 = "Host:\0" @@ -223,6 +226,9 @@ static const char wget_user_headers[] ALIGN1 = # if ENABLE_FEATURE_WGET_AUTHENTICATION "Authorization:\0" "Proxy-Authorization:\0" +# endif +# if ENABLE_PLATFORM_MINGW32 + "Content-Length:\0" # endif ; # define USR_HEADER_HOST (G.user_headers & HDR_HOST) @@ -231,6 +237,7 @@ static const char wget_user_headers[] ALIGN1 = # 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) +# define USR_HEADER_CONTENT_LENGTH (G.user_headers & HDR_CONTENT_LENGTH) #else /* No long options, no user-headers :( */ # define USR_HEADER_HOST 0 # define USR_HEADER_USER_AGENT 0 @@ -238,6 +245,7 @@ static const char wget_user_headers[] ALIGN1 = # define USR_HEADER_CONTENT_TYPE 0 # define USR_HEADER_AUTH 0 # define USR_HEADER_PROXY_AUTH 0 +# define USR_HEADER_CONTENT_LENGTH 0 #endif /* Globals */ @@ -1303,6 +1311,18 @@ static void download_one_url(const char *url) "Content-Type: application/x-www-form-urlencoded\r\n" ); } +# if ENABLE_PLATFORM_MINGW32 + if (!USR_HEADER_CONTENT_LENGTH) + SENDFMT(sfp, "Content-Length: %u\r\n", + (int)strlen(G.post_data) + ); + SENDFMT(sfp, + "\r\n" + "%s", + G.post_data + ); + } else +# else SENDFMT(sfp, "Content-Length: %u\r\n" "\r\n" @@ -1310,6 +1330,7 @@ static void download_one_url(const char *url) (int) strlen(G.post_data), G.post_data ); } else +# endif #endif { SENDFMT(sfp, "\r\n"); -- cgit v1.2.3-55-g6feb