Support for all outputs from `decode_package/3`

11 views
Skip to first unread message

Omar Yasin

unread,
Jul 11, 2013, 3:32:44 PM7/11/13
to moch...@googlegroups.com
Hey,

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:
https://github.com/omarkj/mochiweb/commit/d2fb1be3df69ca9acd9b43b01638e42d803988f9

I've opened a pull request to the main mochiweb repository as well:
https://github.com/mochi/mochiweb/pull/114

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.

Cheers,
Ómar Kjartan Yasin
Reply all
Reply to author
Forward
0 new messages