[BusyBox] wget proxy support

Matt Kraai kraai at alumni.carnegiemellon.edu
Thu Dec 7 19:08:48 UTC 2000


Howdy,

I believe that the attached patch adds simple proxy support to wget.
However, I don't know how to test it at the moment, so I would
appreciate it if someone else who normally uses a proxy would.  To do so
(for the source-code-reading-impaired), just set the http_proxy
environment variable to the URL of your proxy (e.g.,
http://my.proxy.museum:47/).

Matt
-------------- next part --------------
Index: utility.c
===================================================================
RCS file: /var/cvs/busybox/utility.c,v
retrieving revision 1.166
diff -u -r1.166 utility.c
--- utility.c	2000/12/05 20:10:27	1.166
+++ utility.c	2000/12/07 19:05:11
@@ -611,7 +611,7 @@
  * location, and do something (something specified
  * by the fileAction and dirAction function pointers).
  *
- * Unfortunatly, while nftw(3) could replace this and reduce 
+ * Unfortunately, while nftw(3) could replace this and reduce 
  * code size a bit, nftw() wasn't supported before GNU libc 2.1, 
  * and so isn't sufficiently portable to take over since glibc2.1
  * is so stinking huge.
@@ -1444,7 +1444,7 @@
 }
 #endif
 
-#if defined BB_FEATURE_NFSMOUNT || defined BB_SH || defined BB_LS
+#if defined BB_FEATURE_NFSMOUNT || defined BB_LS || defined BB_SH || defined BB_WGET
 # ifndef DMALLOC
 extern char * xstrdup (const char *s) {
 	char *t;
Index: wget.c
===================================================================
RCS file: /var/cvs/busybox/wget.c,v
retrieving revision 1.9
diff -u -r1.9 wget.c
--- wget.c	2000/12/07 03:55:35	1.9
+++ wget.c	2000/12/07 19:04:35
@@ -52,6 +52,7 @@
 {
 	FILE *sfp;					/* socket to web server				*/
 	char *uri_host, *uri_path;	/* parsed from command line url		*/
+	char *proxy;
 	int uri_port;
 	char *s, buf[512];
 	int n;
@@ -101,10 +102,20 @@
 
 	if (do_continue && !fname_out)
 		fatalError("cannot specify continue (-c) without a filename (-O)\n");
+
 	/*
-	 * Parse url into components.
+	 * Use the proxy if necessary.
 	 */
-	parse_url(argv[optind], &uri_host, &uri_port, &uri_path);
+	if ((proxy = getenv("http_proxy")) != NULL) {
+		proxy = xstrdup(proxy);
+		parse_url(proxy, &uri_host, &uri_port, &uri_path);
+		uri_path = argv[optind];
+	} else {
+		/*
+		 * Parse url into components.
+		 */
+		parse_url(argv[optind], &uri_host, &uri_port, &uri_path);
+	}
 
 	/*
 	 * Open socket to server.


More information about the busybox mailing list