diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-10 13:23:45 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-10 13:23:45 +0100 |
commit | 9213a55bf0cc833d024975865a96a762b7a90b62 (patch) | |
tree | 5153df732566e468fcd30e088aa1dd2e741e584e /networking/wget.c | |
parent | aaf091f97dce15460b52d47c95cac81762be7612 (diff) | |
download | busybox-w32-9213a55bf0cc833d024975865a96a762b7a90b62.tar.gz busybox-w32-9213a55bf0cc833d024975865a96a762b7a90b62.tar.bz2 busybox-w32-9213a55bf0cc833d024975865a96a762b7a90b62.zip |
wget: use closed HTTP/1.1 connection, stop when we dl'ed $content_len bytes
function old new delta
retrieve_file_data 353 367 +14
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/wget.c')
-rw-r--r-- | networking/wget.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/networking/wget.c b/networking/wget.c index 74d90040f..931882fde 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -510,8 +510,11 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd) | |||
510 | G.transferred += n; | 510 | G.transferred += n; |
511 | progress_meter(PROGRESS_BUMP); | 511 | progress_meter(PROGRESS_BUMP); |
512 | #endif | 512 | #endif |
513 | if (G.got_clen) | 513 | if (G.got_clen) { |
514 | G.content_len -= n; | 514 | G.content_len -= n; |
515 | if (G.content_len == 0) | ||
516 | break; | ||
517 | } | ||
515 | } | 518 | } |
516 | 519 | ||
517 | if (!G.chunked) | 520 | if (!G.chunked) |
@@ -709,6 +712,11 @@ int wget_main(int argc UNUSED_PARAM, char **argv) | |||
709 | fprintf(sfp, "Host: %s\r\nUser-Agent: %s\r\n", | 712 | fprintf(sfp, "Host: %s\r\nUser-Agent: %s\r\n", |
710 | target.host, user_agent); | 713 | target.host, user_agent); |
711 | 714 | ||
715 | /* Ask server to close the connection as soon as we are done | ||
716 | * (IOW: we do not intend to send more requests) | ||
717 | */ | ||
718 | fprintf(sfp, "Connection: close\r\n"); | ||
719 | |||
712 | #if ENABLE_FEATURE_WGET_AUTHENTICATION | 720 | #if ENABLE_FEATURE_WGET_AUTHENTICATION |
713 | if (target.user) { | 721 | if (target.user) { |
714 | fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6, | 722 | fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6, |
@@ -722,22 +730,25 @@ int wget_main(int argc UNUSED_PARAM, char **argv) | |||
722 | 730 | ||
723 | if (G.beg_range) | 731 | if (G.beg_range) |
724 | fprintf(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); | 732 | fprintf(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); |
733 | |||
725 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | 734 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
726 | if (extra_headers) | 735 | if (extra_headers) |
727 | fputs(extra_headers, sfp); | 736 | fputs(extra_headers, sfp); |
728 | 737 | ||
729 | if (opt & WGET_OPT_POST_DATA) { | 738 | if (opt & WGET_OPT_POST_DATA) { |
730 | char *estr = URL_escape(post_data); | 739 | char *estr = URL_escape(post_data); |
731 | fprintf(sfp, "Content-Type: application/x-www-form-urlencoded\r\n"); | 740 | fprintf(sfp, |
732 | fprintf(sfp, "Content-Length: %u\r\n" "\r\n" "%s", | 741 | "Content-Type: application/x-www-form-urlencoded\r\n" |
733 | (int) strlen(estr), estr); | 742 | "Content-Length: %u\r\n" |
734 | /*fprintf(sfp, "Connection: Keep-Alive\r\n\r\n");*/ | 743 | "\r\n" |
735 | /*fprintf(sfp, "%s\r\n", estr);*/ | 744 | "%s", |
745 | (int) strlen(estr), estr | ||
746 | ); | ||
736 | free(estr); | 747 | free(estr); |
737 | } else | 748 | } else |
738 | #endif | 749 | #endif |
739 | { /* If "Connection:" is needed, document why */ | 750 | { |
740 | fprintf(sfp, /* "Connection: close\r\n" */ "\r\n"); | 751 | fprintf(sfp, "\r\n"); |
741 | } | 752 | } |
742 | 753 | ||
743 | fflush(sfp); | 754 | fflush(sfp); |