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?
EDIT:
More info. Our server is a websocket service. We wish to allow people without a ws supporting browser to use it so we use a flash object to do websocket when the browser can't. The flash object needs to get a flash policy file. Flash forces the file to be in one of two places: - port 843 (flash hard coded) - the port of the ws service The flash protocol is NOT HTTP based. Amazon ELB does not allow port forwarding for most ports below 1024, so we implemented the flash server in the same port via a patch to mochiweb (https://github.com/nivertech/mochiweb/tree/ori_flash_170811).
Any advice?