[PATCH] - Adds support for custom error pages in httpd

Pierre Métras genepi at sympatico.ca
Fri Jul 6 08:15:04 PDT 2007


Package: busybox
Version: svn revision 18994
Severity: wishlist

Hello list,

Here is a patch to add support for user defined error pages in httpd server.

The syntax of httpd.conf file has been extended to let the user defined custom 
error pages. Lines of the format:
        Ennn:path/error_nnn.html
mean that for HTTP status nnn, the server will respond with the page 
path/error_nnn.html. Absolute and relative to `home_httpd` paths are 
supported, but error pages can't be CGI or scripts (too big a change to 
httpd.c to add this feature). Also, error pages definitions are only 
supported in the root config file.

For instance, adding the following line
        E404:e404.html
to /etc/httpd.conf file displays the custom page /e404.html whenever a page is 
not found, instead of the terse message "404 Not Found".


I have a linux router running X-wrt (www.x-wrt.org), so using httpd busybox. I 
have configured it to block ad servers with a procedure similar to the ones 
described here: http://www.debian-administration.org/articles/535. With this 
patch of httpd, I could replace all the ads in a web page by a custom page or 
a small image, instead of getting a "404 Not Found" text.


$ make bloatcheck
...
function                                             old     new   delta
parse_conf                                          1201    1436    +235
sendHeaders                                          461     571    +110
sendFile                                             252     317     +65
httpResponseNames                                    108     144     +36
handleIncoming                                      2032    2038      +6
.rodata                                           138727  138663     -64
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/1 up/down: 452/-64)           Total: 388 bytes
   text    data     bss     dec     hex filename
 636180    3124   12800  652104   9f348 busybox_old
 636589    3288   12800  652677   9f585 busybox_unstripped


I have tested it in limited situations, so if others can test it and tell me 
if it works as they expected, it would be appreciated. By default, this 
configuration option is not enabled when compiling busybox.

Last: this patch corrects also the last TODO in the httpd.c file, replacing a 
few lines of code by a call to sendfile.

-- Pierre Métras
-------------- next part --------------
A non-text attachment was scrubbed...
Name: httpd_with_error_pages.patch
Type: text/x-diff
Size: 10828 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20070706/75e93f94/attachment-0001.bin 


More information about the busybox mailing list