Support for all outputs from `decode_package/3`

Skip to first unread message

Omar Yasin

Jul 11, 2013, 3:32:44 PM7/11/13

I was having problems with mochiweb when a client issues an HTTP
command like this:

CONNECT host:port HTTP/1.1

This will be decoded using `erlang:decode_package/3` and will cause an
error in the
file `mochiweb.erl` causing that acceptor to crash with a function
clause error. This
is happening because the output of `decode_packge/3` is `{scheme,
HttpString, HttpString}`
which is not handled in the function `mochiweb:new_request/1`.

I patched that file to support all possible outputs from
`decode_package/3` so I'm able
to return an error message to the clients. Both NGINX and Apache
return 400 by default.

The commit is here:

I've opened a pull request to the main mochiweb repository as well:

I'm not sure requests like this should be forwared to the user of the
mochiweb server
or just be unsupported. If they are supposed to be unsupported an
error (400?) should
probably be returned instead.

Ómar Kjartan Yasin
Reply all
Reply to author
0 new messages