On Wednesday 17 October 2007 10:56, Alex Landau wrote: > --- Alex Landau <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > The attached patch adds an option to set the default page to display for a > > URL like > > http://hostname/ instead of index.html. The option is compile-time > > selectable and the > > filename is config-file choosable. The file may also be a CGI script (if > > CGI is > > compiled > > in). > > > > Any comments?
I removed dup() below:
cgi_io_loop_and_exit(proxy_fd, dup(proxy_fd), length);
Is it needed?
Also I edited code parts which looked like "if ((A = expr) == B) ... ",
and removed trailing whitespace.
Here you allocate 8k buffer and copy there all headers from client:
char *headers = xmalloc(IOBUF_SIZE);
...
/* Read until blank line for HTTP version specified, else parse
immediate */
while (1) {
alarm(HEADER_READ_TIMEOUT);
if (!get_line())
break; /* EOF or error or empty line */
if (DEBUG)
bb_error_msg("header: '%s'", iobuf);
#if ENABLE_FEATURE_HTTPD_PROXY
if (headers_ptr - headers < IOBUF_SIZE) {
int len = strlen(iobuf);
if (len > IOBUF_SIZE - (headers_ptr - headers)
- 2)
len = IOBUF_SIZE - (headers_ptr -
headers) - 2;
memcpy(headers_ptr, iobuf, len);
headers_ptr += len;
headers_ptr[0] = '\r';
headers_ptr[1] = '\n';
headers_ptr += 2;
}
#endif
But you use it only if request happens to be one of the proxied
requests:
proxy_entry = find_proxy_entry(urlcopy);
if (proxy_entry != NULL) {
....
write(proxy_fd, headers, headers_ptr - headers);
write(proxy_fd, "\r\n", 2);
cgi_io_loop_and_exit(proxy_fd, proxy_fd, length);
}
Can you check find_proxy_entry(urlcopy) earlier and do xmalloc
and copying only if needed?
I am attaching modified httpd.c, please base your further work on it.
Thanks Alex for your work.
--
vda
httpd.c.bz2
Description: BZip2 compressed data
_______________________________________________ busybox mailing list [email protected] http://busybox.net/cgi-bin/mailman/listinfo/busybox
