Hi busybox devs, It's been a long time! About 17 years since my last submission 
:-)

I was just trying to make some coffee with busybox, and I noticed it doesn't 
support RFC 2324 (Hyper Text Coffee Pot Control Protocol). Attached is a patch 
that adds support for the standard. Although I should mention it's not full 
support for the standard; I take my coffee black, so I didn't implement WHEN 
and Accept-Additions, but I'm sure someone else can if they need creamer 
(although some Kahlua wouldn't go amiss with this winter weather...)

The patch includes a configuration file option "T" that sets if the host is a 
teapot or not. The default is teapot mode, for portability (coffee brewing 
operations shouldn't happen on a teapot).

Sample operation:

$ echo "T:1" > cgi-bin/httpd.conf 
$ curl -d 'start' -H "Content-Type: application/coffee-pot-command" -X BREW 
http://localhost:6789/cgi-bin/coffeepot
<HTML><HEAD><TITLE>418 I'm a teapot</TITLE></HEAD>
<BODY><H1>418 I'm a teapot</H1>
The web server is a teapot
</BODY></HTML>
$ echo "T:0" > cgi-bin/httpd.conf
$ curl -d 'start' -H "Content-Type: application/coffee-pot-command" -X BREW 
http://localhost:6789/cgi-bin/coffeepot
Brewing coffee!

Also note that the patch fixes a Content-Length bug I found in send_headers():

    The function always returns the Content-Length, which is always set to the 
length of a file (for example, if there was a request of a file, the file's 
size is taken - but then some error might be thrown after this point). After 
the Content-Length is set, if infoString was set (the text of a response code) 
the resulting HTML output's length bears no relation to the file size it 
previously set as the Content-Length. Therefore the Content-Length needs to be 
set to either the file size, or the length of the infoString HTML message. The 
patch includes a change to calculate the size of the infoString template and 
return that length if infoString was set.

Attachment: HTCPCP.diff.gz
Description: application/gzip

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to