aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/wget.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/networking/wget.c b/networking/wget.c
index 313e2e6ff..823a053db 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -185,7 +185,7 @@ int wget_main(int argc, char **argv)
185 int got_clen = 0; /* got content-length: from server */ 185 int got_clen = 0; /* got content-length: from server */
186 FILE *output; /* socket to web server */ 186 FILE *output; /* socket to web server */
187 int quiet_flag = FALSE; /* Be verry, verry quiet... */ 187 int quiet_flag = FALSE; /* Be verry, verry quiet... */
188 int noproxy = 0; /* Use proxies if env vars are set */ 188 int use_proxy = 1; /* Use proxies if env vars are set */
189 char *proxy_flag = "on"; /* Use proxies if env vars are set */ 189 char *proxy_flag = "on"; /* Use proxies if env vars are set */
190 190
191 /* 191 /*
@@ -200,11 +200,9 @@ int wget_main(int argc, char **argv)
200 if (opt & WGET_OPT_QUIET) { 200 if (opt & WGET_OPT_QUIET) {
201 quiet_flag = TRUE; 201 quiet_flag = TRUE;
202 } 202 }
203 if (strcmp(proxy_flag, "on") == 0) { 203 if (strcmp(proxy_flag, "off") == 0) {
204 /* Use the proxy if necessary. */ 204 /* Use the proxy if necessary. */
205 proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); 205 use_proxy = 0;
206 if (proxy)
207 parse_url(bb_xstrdup(proxy), &server);
208 } 206 }
209 if (opt & WGET_OPT_HEADER) { 207 if (opt & WGET_OPT_HEADER) {
210 while (headers_llist) { 208 while (headers_llist) {
@@ -230,10 +228,13 @@ int wget_main(int argc, char **argv)
230 /* 228 /*
231 * Use the proxy if necessary. 229 * Use the proxy if necessary.
232 */ 230 */
233 if (!noproxy) { 231 if (use_proxy) {
234 proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); 232 proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy");
235 if (proxy) 233 if (proxy && *proxy) {
236 parse_url(bb_xstrdup(proxy), &server); 234 parse_url(bb_xstrdup(proxy), &server);
235 } else {
236 use_proxy = 0;
237 }
237 } 238 }
238 239
239 /* Guess an output filename */ 240 /* Guess an output filename */
@@ -293,7 +294,7 @@ int wget_main(int argc, char **argv)
293 server.host, inet_ntoa(s_in.sin_addr), ntohs(server.port)); 294 server.host, inet_ntoa(s_in.sin_addr), ntohs(server.port));
294 } 295 }
295 296
296 if (proxy || !target.is_ftp) { 297 if (use_proxy || !target.is_ftp) {
297 /* 298 /*
298 * HTTP session 299 * HTTP session
299 */ 300 */
@@ -312,7 +313,7 @@ int wget_main(int argc, char **argv)
312 /* 313 /*
313 * Send HTTP request. 314 * Send HTTP request.
314 */ 315 */
315 if (proxy) { 316 if (use_proxy) {
316 const char *format = "GET %stp://%s:%d/%s HTTP/1.1\r\n"; 317 const char *format = "GET %stp://%s:%d/%s HTTP/1.1\r\n";
317#ifdef CONFIG_FEATURE_WGET_IP6_LITERAL 318#ifdef CONFIG_FEATURE_WGET_IP6_LITERAL
318 if (strchr (target.host, ':')) 319 if (strchr (target.host, ':'))
@@ -332,7 +333,7 @@ int wget_main(int argc, char **argv)
332 fprintf(sfp, "Authorization: Basic %s\r\n", 333 fprintf(sfp, "Authorization: Basic %s\r\n",
333 base64enc(target.user, buf, sizeof(buf))); 334 base64enc(target.user, buf, sizeof(buf)));
334 } 335 }
335 if (proxy && server.user) { 336 if (use_proxy && server.user) {
336 fprintf(sfp, "Proxy-Authorization: Basic %s\r\n", 337 fprintf(sfp, "Proxy-Authorization: Basic %s\r\n",
337 base64enc(server.user, buf, sizeof(buf))); 338 base64enc(server.user, buf, sizeof(buf)));
338 } 339 }
@@ -400,7 +401,7 @@ read_response:
400 target.path = bb_xstrdup(s+1); 401 target.path = bb_xstrdup(s+1);
401 else { 402 else {
402 parse_url(bb_xstrdup(s), &target); 403 parse_url(bb_xstrdup(s), &target);
403 if (!proxy) { 404 if (use_proxy == 0) {
404 server.host = target.host; 405 server.host = target.host;
405 server.port = target.port; 406 server.port = target.port;
406 } 407 }
@@ -525,7 +526,7 @@ read_response:
525 if (quiet_flag==FALSE) 526 if (quiet_flag==FALSE)
526 progressmeter(1); 527 progressmeter(1);
527#endif 528#endif
528 if (!proxy && target.is_ftp) { 529 if ((use_proxy == 0) && target.is_ftp) {
529 fclose(dfp); 530 fclose(dfp);
530 if (ftpcmd(NULL, NULL, sfp, buf) != 226) 531 if (ftpcmd(NULL, NULL, sfp, buf) != 226)
531 bb_error_msg_and_die("ftp error: %s", buf+4); 532 bb_error_msg_and_die("ftp error: %s", buf+4);
@@ -551,7 +552,7 @@ void parse_url(char *url, struct host_info *h)
551 bb_error_msg_and_die("not an http or ftp url: %s", url); 552 bb_error_msg_and_die("not an http or ftp url: %s", url);
552 553
553 sp = strchr(h->host, '/'); 554 sp = strchr(h->host, '/');
554 if (sp != NULL) { 555 if (sp) {
555 *sp++ = '\0'; 556 *sp++ = '\0';
556 h->path = sp; 557 h->path = sp;
557 } else 558 } else
@@ -837,7 +838,7 @@ progressmeter(int flag)
837 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 838 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
838 * SUCH DAMAGE. 839 * SUCH DAMAGE.
839 * 840 *
840 * $Id: wget.c,v 1.68 2004/01/31 08:08:57 bug1 Exp $ 841 * $Id: wget.c,v 1.69 2004/02/22 00:27:34 bug1 Exp $
841 */ 842 */
842 843
843 844