diff options
Diffstat (limited to 'networking/wget.c')
-rw-r--r-- | networking/wget.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/networking/wget.c b/networking/wget.c index ec3767793..6a64836fb 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 | }; |
218 | static const char wget_user_headers[] ALIGN1 = | 221 | static 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 */ |
@@ -517,6 +525,9 @@ static int ftpcmd(const char *s1, const char *s2, FILE *fp) | |||
517 | fprintf(stderr, "--> %s%s\n\n", s1, s2); | 525 | fprintf(stderr, "--> %s%s\n\n", s1, s2); |
518 | fflush(fp); | 526 | fflush(fp); |
519 | log_io("> %s%s", s1, s2); | 527 | log_io("> %s%s", s1, s2); |
528 | #if ENABLE_PLATFORM_MINGW32 | ||
529 | fseek(fp, 0L, SEEK_CUR); | ||
530 | #endif | ||
520 | } | 531 | } |
521 | 532 | ||
522 | /* Read until "Nxx something" is received */ | 533 | /* Read until "Nxx something" is received */ |
@@ -524,6 +535,9 @@ static int ftpcmd(const char *s1, const char *s2, FILE *fp) | |||
524 | do { | 535 | do { |
525 | fgets_trim_sanitize(fp, "%s\n"); | 536 | fgets_trim_sanitize(fp, "%s\n"); |
526 | } while (!isdigit(G.wget_buf[0]) || G.wget_buf[3] != ' '); | 537 | } while (!isdigit(G.wget_buf[0]) || G.wget_buf[3] != ' '); |
538 | #if ENABLE_PLATFORM_MINGW32 | ||
539 | fseek(fp, 0L, SEEK_CUR); | ||
540 | #endif | ||
527 | 541 | ||
528 | G.wget_buf[3] = '\0'; | 542 | G.wget_buf[3] = '\0'; |
529 | result = xatoi_positive(G.wget_buf); | 543 | result = xatoi_positive(G.wget_buf); |
@@ -766,6 +780,7 @@ static int spawn_https_helper_openssl(const char *host, unsigned port) | |||
766 | #endif | 780 | #endif |
767 | 781 | ||
768 | #if ENABLE_FEATURE_WGET_HTTPS | 782 | #if ENABLE_FEATURE_WGET_HTTPS |
783 | # if !ENABLE_PLATFORM_MINGW32 | ||
769 | static void spawn_ssl_client(const char *host, int network_fd, int flags) | 784 | static void spawn_ssl_client(const char *host, int network_fd, int flags) |
770 | { | 785 | { |
771 | int sp[2]; | 786 | int sp[2]; |
@@ -820,6 +835,31 @@ static void spawn_ssl_client(const char *host, int network_fd, int flags) | |||
820 | close(sp[1]); | 835 | close(sp[1]); |
821 | xmove_fd(sp[0], network_fd); | 836 | xmove_fd(sp[0], network_fd); |
822 | } | 837 | } |
838 | # else | ||
839 | static void spawn_ssl_client(const char *host, int network_fd, int flags) | ||
840 | { | ||
841 | int fd1; | ||
842 | char *servername, *p, *cmd; | ||
843 | |||
844 | servername = xstrdup(host); | ||
845 | p = strrchr(servername, ':'); | ||
846 | if (p) *p = '\0'; | ||
847 | |||
848 | fflush_all(); | ||
849 | |||
850 | cmd = xasprintf("ssl_client -h %p -n %s%s", | ||
851 | (void *)_get_osfhandle(network_fd), servername, | ||
852 | flags & TLSLOOP_EXIT_ON_LOCAL_EOF ? " -e" : ""); | ||
853 | |||
854 | if ((fd1=mingw_popen_fd("ssl_client", cmd, "b", -1, NULL)) == -1) { | ||
855 | bb_perror_msg_and_die("can't execute ssl_client"); | ||
856 | } | ||
857 | |||
858 | free(cmd); | ||
859 | free(servername); | ||
860 | xmove_fd(fd1, network_fd); | ||
861 | } | ||
862 | # endif | ||
823 | #endif | 863 | #endif |
824 | 864 | ||
825 | #if ENABLE_FEATURE_WGET_FTP | 865 | #if ENABLE_FEATURE_WGET_FTP |
@@ -1273,6 +1313,18 @@ static void download_one_url(const char *url) | |||
1273 | "Content-Type: application/x-www-form-urlencoded\r\n" | 1313 | "Content-Type: application/x-www-form-urlencoded\r\n" |
1274 | ); | 1314 | ); |
1275 | } | 1315 | } |
1316 | # if ENABLE_PLATFORM_MINGW32 | ||
1317 | if (!USR_HEADER_CONTENT_LENGTH) | ||
1318 | SENDFMT(sfp, "Content-Length: %u\r\n", | ||
1319 | (int)strlen(G.post_data) | ||
1320 | ); | ||
1321 | SENDFMT(sfp, | ||
1322 | "\r\n" | ||
1323 | "%s", | ||
1324 | G.post_data | ||
1325 | ); | ||
1326 | } else | ||
1327 | # else | ||
1276 | SENDFMT(sfp, | 1328 | SENDFMT(sfp, |
1277 | "Content-Length: %u\r\n" | 1329 | "Content-Length: %u\r\n" |
1278 | "\r\n" | 1330 | "\r\n" |
@@ -1280,6 +1332,7 @@ static void download_one_url(const char *url) | |||
1280 | (int) strlen(G.post_data), G.post_data | 1332 | (int) strlen(G.post_data), G.post_data |
1281 | ); | 1333 | ); |
1282 | } else | 1334 | } else |
1335 | # endif | ||
1283 | #endif | 1336 | #endif |
1284 | { | 1337 | { |
1285 | SENDFMT(sfp, "\r\n"); | 1338 | SENDFMT(sfp, "\r\n"); |