Re: Patch to add support for RFC2324 (HTCPCP)

2021-11-28 Thread Kang-Che Sung
On Mon, Nov 29, 2021 at 5:16 AM Peter Willis  wrote:
>
> 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
> 418 I'm a teapot
> 418 I'm a teapot
> The web server is a teapot
> 
> $ 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.

Just wondering. Is this an out-of-season April Fools joke? (Sorry for
quoting that guy at Blizzcon.)

But I have a serious question here: I don't see the ".cup" file
extension or the "vessel/cup" MIME type defined anywhere in the HTCPCP
spec. Where are those keywords from?
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Patch to add support for RFC2324 (HTCPCP)

2021-11-28 Thread Peter Willis
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
418 I'm a teapot
418 I'm a teapot
The web server is a teapot

$ 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.

HTCPCP.diff.gz
Description: application/gzip
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox