aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/wget.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/networking/wget.c b/networking/wget.c
index 1991a1072..8520fe2b9 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -13,8 +13,9 @@
13//usage: IF_FEATURE_WGET_LONG_OPTIONS( 13//usage: IF_FEATURE_WGET_LONG_OPTIONS(
14//usage: "[-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FILE]\n" 14//usage: "[-c|--continue] [-s|--spider] [-q|--quiet] [-O|--output-document FILE]\n"
15//usage: " [--header 'header: value'] [-Y|--proxy on/off] [-P DIR]\n" 15//usage: " [--header 'header: value'] [-Y|--proxy on/off] [-P DIR]\n"
16//usage: " [--no-check-certificate] [-U|--user-agent AGENT]" 16/* Since we ignore these opts, we don't show them in --help */
17//usage: IF_FEATURE_WGET_TIMEOUT(" [-T SEC]") " URL..." 17/* //usage: " [--no-check-certificate] [--no-cache]" */
18//usage: " [-U|--user-agent AGENT]" IF_FEATURE_WGET_TIMEOUT(" [-T SEC]") " URL..."
18//usage: ) 19//usage: )
19//usage: IF_NOT_FEATURE_WGET_LONG_OPTIONS( 20//usage: IF_NOT_FEATURE_WGET_LONG_OPTIONS(
20//usage: "[-csq] [-O FILE] [-Y on/off] [-P DIR] [-U AGENT]" 21//usage: "[-csq] [-O FILE] [-Y on/off] [-P DIR] [-U AGENT]"
@@ -35,8 +36,11 @@
35 36
36#include "libbb.h" 37#include "libbb.h"
37 38
38//#define log_io(...) bb_error_msg(__VA_ARGS__) 39#if 0
39#define log_io(...) ((void)0) 40# define log_io(...) bb_error_msg(__VA_ARGS__)
41#else
42# define log_io(...) ((void)0)
43#endif
40 44
41 45
42struct host_info { 46struct host_info {
@@ -316,8 +320,6 @@ static char *gethdr(FILE *fp)
316 char *s, *hdrval; 320 char *s, *hdrval;
317 int c; 321 int c;
318 322
319 /* *istrunc = 0; */
320
321 /* retrieve header line */ 323 /* retrieve header line */
322 c = fgets_and_trim(fp); 324 c = fgets_and_trim(fp);
323 325
@@ -415,7 +417,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_
415 417
416 *dfpp = open_socket(lsa); 418 *dfpp = open_socket(lsa);
417 419
418 if (G.beg_range) { 420 if (G.beg_range != 0) {
419 sprintf(G.wget_buf, "REST %"OFF_FMT"u", G.beg_range); 421 sprintf(G.wget_buf, "REST %"OFF_FMT"u", G.beg_range);
420 if (ftpcmd(G.wget_buf, NULL, sfp) == 350) 422 if (ftpcmd(G.wget_buf, NULL, sfp) == 350)
421 G.content_len -= G.beg_range; 423 G.content_len -= G.beg_range;
@@ -675,7 +677,7 @@ static void download_one_url(const char *url)
675 } 677 }
676#endif 678#endif
677 679
678 if (G.beg_range) 680 if (G.beg_range != 0)
679 fprintf(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); 681 fprintf(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range);
680 682
681#if ENABLE_FEATURE_WGET_LONG_OPTIONS 683#if ENABLE_FEATURE_WGET_LONG_OPTIONS
@@ -748,9 +750,11 @@ However, in real world it was observed that some web servers
748 case 302: 750 case 302:
749 case 303: 751 case 303:
750 break; 752 break;
751 case 206: 753 case 206: /* Partial Content */
752 if (G.beg_range) 754 if (G.beg_range != 0)
755 /* "Range:..." worked. Good. */
753 break; 756 break;
757 /* Partial Content even though we did not ask for it??? */
754 /* fall through */ 758 /* fall through */
755 default: 759 default:
756 bb_error_msg_and_die("server returned error: %s", sanitize_string(G.wget_buf)); 760 bb_error_msg_and_die("server returned error: %s", sanitize_string(G.wget_buf));
@@ -878,6 +882,8 @@ int wget_main(int argc UNUSED_PARAM, char **argv)
878 "post-data\0" Required_argument "\xfd" 882 "post-data\0" Required_argument "\xfd"
879 /* Ignored (we don't do ssl) */ 883 /* Ignored (we don't do ssl) */
880 "no-check-certificate\0" No_argument "\xfc" 884 "no-check-certificate\0" No_argument "\xfc"
885 /* Ignored (we don't support caching) */
886 "no-cache\0" No_argument "\xfb"
881 ; 887 ;
882#endif 888#endif
883 889