diff options
| author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-09-02 15:30:26 +0000 |
|---|---|---|
| committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-09-02 15:30:26 +0000 |
| commit | bfbc4ebf4045b834ed080e7b6f0ebe2c789fb5f1 (patch) | |
| tree | 4d9e3ec01f0509f3e6b6e4ccaf9f0ce227011ae7 | |
| parent | 686298d6fb155deb4490eb609a19c59d97b1e2f6 (diff) | |
| download | busybox-w32-bfbc4ebf4045b834ed080e7b6f0ebe2c789fb5f1.tar.gz busybox-w32-bfbc4ebf4045b834ed080e7b6f0ebe2c789fb5f1.tar.bz2 busybox-w32-bfbc4ebf4045b834ed080e7b6f0ebe2c789fb5f1.zip | |
- patch from Csaba Henk to make the "User-Agent" header field configurable.
| -rw-r--r-- | include/usage.h | 4 | ||||
| -rw-r--r-- | networking/wget.c | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/include/usage.h b/include/usage.h index 0f95708c5..3e3e8c84a 100644 --- a/include/usage.h +++ b/include/usage.h | |||
| @@ -3396,7 +3396,8 @@ USE_FEATURE_START_STOP_DAEMON_FANCY( \ | |||
| 3396 | 3396 | ||
| 3397 | #define wget_trivial_usage \ | 3397 | #define wget_trivial_usage \ |
| 3398 | "[-c|--continue] [-q|--quiet] [-O|--output-document file]\n" \ | 3398 | "[-c|--continue] [-q|--quiet] [-O|--output-document file]\n" \ |
| 3399 | "\t\t[--header 'header: value'] [-Y|--proxy on/off] [-P DIR] url" | 3399 | "\t\t[--header 'header: value'] [-Y|--proxy on/off] [-P DIR]\n" \ |
| 3400 | "\t\t[-U|--user-agent agent] url" | ||
| 3400 | #define wget_full_usage \ | 3401 | #define wget_full_usage \ |
| 3401 | "wget retrieves files via HTTP or FTP\n\n" \ | 3402 | "wget retrieves files via HTTP or FTP\n\n" \ |
| 3402 | "Options:\n" \ | 3403 | "Options:\n" \ |
| @@ -3404,6 +3405,7 @@ USE_FEATURE_START_STOP_DAEMON_FANCY( \ | |||
| 3404 | "\t-q\tquiet mode - do not print\n" \ | 3405 | "\t-q\tquiet mode - do not print\n" \ |
| 3405 | "\t-P\tSet directory prefix to DIR\n" \ | 3406 | "\t-P\tSet directory prefix to DIR\n" \ |
| 3406 | "\t-O\tsave to filename ('-' for stdout)\n" \ | 3407 | "\t-O\tsave to filename ('-' for stdout)\n" \ |
| 3408 | "\t-U\tadjust 'User-Agent' field\n" \ | ||
| 3407 | "\t-Y\tuse proxy ('on' or 'off')" | 3409 | "\t-Y\tuse proxy ('on' or 'off')" |
| 3408 | 3410 | ||
| 3409 | #define which_trivial_usage \ | 3411 | #define which_trivial_usage \ |
diff --git a/networking/wget.c b/networking/wget.c index 42fbeaf99..755515262 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
| @@ -132,6 +132,7 @@ static char *base64enc(unsigned char *p, char *buf, int len) { | |||
| 132 | #define WGET_OPT_HEADER 16 | 132 | #define WGET_OPT_HEADER 16 |
| 133 | #define WGET_OPT_PREFIX 32 | 133 | #define WGET_OPT_PREFIX 32 |
| 134 | #define WGET_OPT_PROXY 64 | 134 | #define WGET_OPT_PROXY 64 |
| 135 | #define WGET_OPT_USER_AGENT 128 | ||
| 135 | 136 | ||
| 136 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | 137 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
| 137 | static const struct option wget_long_options[] = { | 138 | static const struct option wget_long_options[] = { |
| @@ -142,6 +143,7 @@ static const struct option wget_long_options[] = { | |||
| 142 | { "header", 1, NULL, 131 }, | 143 | { "header", 1, NULL, 131 }, |
| 143 | { "directory-prefix",1, NULL, 'P' }, | 144 | { "directory-prefix",1, NULL, 'P' }, |
| 144 | { "proxy", 1, NULL, 'Y' }, | 145 | { "proxy", 1, NULL, 'Y' }, |
| 146 | { "user-agent", 1, NULL, 'U' }, | ||
| 145 | { 0, 0, 0, 0 } | 147 | { 0, 0, 0, 0 } |
| 146 | }; | 148 | }; |
| 147 | #endif | 149 | #endif |
| @@ -172,6 +174,7 @@ int wget_main(int argc, char **argv) | |||
| 172 | int quiet_flag = FALSE; /* Be verry, verry quiet... */ | 174 | int quiet_flag = FALSE; /* Be verry, verry quiet... */ |
| 173 | int use_proxy = 1; /* Use proxies if env vars are set */ | 175 | int use_proxy = 1; /* Use proxies if env vars are set */ |
| 174 | char *proxy_flag = "on"; /* Use proxies if env vars are set */ | 176 | char *proxy_flag = "on"; /* Use proxies if env vars are set */ |
| 177 | char *user_agent = "Wget"; /* Content of the "User-Agent" header field */ | ||
| 175 | 178 | ||
| 176 | /* | 179 | /* |
| 177 | * Crack command line. | 180 | * Crack command line. |
| @@ -180,9 +183,9 @@ int wget_main(int argc, char **argv) | |||
| 180 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | 183 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
| 181 | bb_applet_long_options = wget_long_options; | 184 | bb_applet_long_options = wget_long_options; |
| 182 | #endif | 185 | #endif |
| 183 | opt = bb_getopt_ulflags(argc, argv, "cq\213O:\203:P:Y:", | 186 | opt = bb_getopt_ulflags(argc, argv, "cq\213O:\203:P:Y:U:", |
| 184 | &fname_out, &headers_llist, | 187 | &fname_out, &headers_llist, |
| 185 | &dir_prefix, &proxy_flag); | 188 | &dir_prefix, &proxy_flag, &user_agent); |
| 186 | if (opt & WGET_OPT_CONTINUE) { | 189 | if (opt & WGET_OPT_CONTINUE) { |
| 187 | ++do_continue; | 190 | ++do_continue; |
| 188 | } | 191 | } |
| @@ -317,7 +320,8 @@ int wget_main(int argc, char **argv) | |||
| 317 | fprintf(sfp, "GET /%s HTTP/1.1\r\n", target.path); | 320 | fprintf(sfp, "GET /%s HTTP/1.1\r\n", target.path); |
| 318 | } | 321 | } |
| 319 | 322 | ||
| 320 | fprintf(sfp, "Host: %s\r\nUser-Agent: Wget\r\n", target.host); | 323 | fprintf(sfp, "Host: %s\r\nUser-Agent: %s\r\n", target.host, |
| 324 | user_agent); | ||
| 321 | 325 | ||
| 322 | #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION | 326 | #ifdef CONFIG_FEATURE_WGET_AUTHENTICATION |
| 323 | if (target.user) { | 327 | if (target.user) { |
