summaryrefslogtreecommitdiff
path: root/networking/wget.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-23 23:21:58 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-23 23:21:58 +0000
commit7534e0834f9ed5059a90a2a5508a6fcdbf8769dc (patch)
treee4170e78725b313334cf558ebedf15f10812b922 /networking/wget.c
parent703aa13ff5e2b795319a3e900c1f8df6e3da47b5 (diff)
downloadbusybox-w32-7534e0834f9ed5059a90a2a5508a6fcdbf8769dc.tar.gz
busybox-w32-7534e0834f9ed5059a90a2a5508a6fcdbf8769dc.tar.bz2
busybox-w32-7534e0834f9ed5059a90a2a5508a6fcdbf8769dc.zip
wget: -100 bytes, reduce stack usage, remove --header length limit
Diffstat (limited to 'networking/wget.c')
-rw-r--r--networking/wget.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/networking/wget.c b/networking/wget.c
index 1b132bea8..91e5e655a 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -111,15 +111,14 @@ static const struct option wget_long_options[] = {
111 111
112int wget_main(int argc, char **argv) 112int wget_main(int argc, char **argv)
113{ 113{
114 int n, try=5, status; 114 int n, status;
115 unsigned opt; 115 int try = 5;
116 int port; 116 int port;
117 unsigned opt;
117 char *proxy = 0; 118 char *proxy = 0;
118 char *dir_prefix=NULL; 119 char *dir_prefix = NULL;
119 char *s, buf[512]; 120 char *s, buf[512];
120 char extra_headers[1024]; 121 char *extra_headers = NULL;
121 char *extra_headers_ptr = extra_headers;
122 int extra_headers_left = sizeof(extra_headers);
123 struct host_info server, target; 122 struct host_info server, target;
124 struct sockaddr_in s_in; 123 struct sockaddr_in s_in;
125 llist_t *headers_llist = NULL; 124 llist_t *headers_llist = NULL;
@@ -149,18 +148,17 @@ int wget_main(int argc, char **argv)
149 /* Use the proxy if necessary. */ 148 /* Use the proxy if necessary. */
150 use_proxy = 0; 149 use_proxy = 0;
151 } 150 }
152 if (opt & WGET_OPT_HEADER) { 151 if (headers_llist) {
152 int size = 1;
153 char *cp;
154 llist_t *ll = headers_llist;
155 while (ll) {
156 size += strlen(ll->data) + 2;
157 ll = ll->link;
158 }
159 extra_headers = cp = xmalloc(size);
153 while (headers_llist) { 160 while (headers_llist) {
154 int arglen = strlen(headers_llist->data); 161 cp += sprintf(cp, "%s\r\n", headers_llist->data);
155 if (extra_headers_left - arglen - 2 <= 0)
156 bb_error_msg_and_die("extra_headers buffer too small "
157 "(need %i)", extra_headers_left - arglen);
158 strcpy(extra_headers_ptr, headers_llist->data);
159 extra_headers_ptr += arglen;
160 extra_headers_left -= ( arglen + 2 );
161 *extra_headers_ptr++ = '\r';
162 *extra_headers_ptr++ = '\n';
163 *(extra_headers_ptr + 1) = 0;
164 headers_llist = headers_llist->link; 162 headers_llist = headers_llist->link;
165 } 163 }
166 } 164 }
@@ -283,9 +281,9 @@ int wget_main(int argc, char **argv)
283 281
284 if (beg_range) 282 if (beg_range)
285 fprintf(sfp, "Range: bytes="OFF_FMT"-\r\n", beg_range); 283 fprintf(sfp, "Range: bytes="OFF_FMT"-\r\n", beg_range);
286 if(extra_headers_left < sizeof(extra_headers)) 284 if (extra_headers)
287 fputs(extra_headers,sfp); 285 fputs(extra_headers, sfp);
288 fprintf(sfp,"Connection: close\r\n\r\n"); 286 fprintf(sfp, "Connection: close\r\n\r\n");
289 287
290 /* 288 /*
291 * Retrieve HTTP response line and check for "200" status code. 289 * Retrieve HTTP response line and check for "200" status code.