[erlang-questions] Handling non http in mochiweb

Bob Ippolito bob@REDACTED
Wed Aug 17 00:00:11 CEST 2011

mochiweb isn't designed to handle this use case, if it doesn't look
like HTTP then the connection is closed and it gets discarded. You
would have to go around mochiweb_http for this purpose. I'd suggest
using an alternate port, or making it look like HTTP.

If I really wanted to do what you say you want to do, I would copy
mochiweb_http.erl to some other name (e.g. sometimes_not_http.erl) and
make the appropriate changes to loop/2 and request/2… then instead of
adding mochiweb_http to your supervisor you'd add sometimes_not_http.
It is not necessary or recommended to make modifications to mochiweb

On Tue, Aug 16, 2011 at 2:40 PM, ori brost <oribrost@REDACTED> wrote:
> I am using mochiweb for a server that may also get a TCP connction to
> which the client sends a simple string (without a newline, the string
> is not http). Mochiweb uses HTTP sockets and therefore fails to detect
> this (i dont even get http_error that i can easily get in mochiweb).
> How can I solve this? Ideally I wish to change mochiweb code to do
> setopt({packet, http_or_raw}) but this kind of thing does not exist.
> How would you recommend handling this? my current idea was to modify
> mochiweb and use erlang:decode_packet, is there a better approach?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list