0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 20:50:24 +00:00
Commit graph

14 commits

Author SHA1 Message Date
Loïc Hoguin
43d14b52cd Give the ListenerPid to the protocol on startup
Also sends a message 'shoot' that can be received by the protocol
to make sure Cowboy has had enough time to fully initialize the
socket. This message should be received before any socket-related
operations are performed.

WebSocket request connections are now moved from the pool 'default'
to the pool 'websocket', meaning we can have a lot of running
WebSockets despite having a low 'max_connections' setting.
2011-08-10 20:28:30 +02:00
Loïc Hoguin
293cf33702 Separate message and packet handling for websockets
Improves the readability of websocket handler code by having
two functions: websocket_handle/3 handles the packets received
from the socket, removing the tuple construct that was otherwise
needed, so only websocket_handle(Data, Req, State) is needed now;
websocket_info/3 handles the messages that the websocket handler
process received, as websocket_info(Info, Req, State).

Both functions return values are handled identically by Cowboy
so nothing changes on that end.
2011-07-19 12:20:16 +02:00
Loïc Hoguin
87366e36ad Call websocket_close/4 *after* throwing the error
This ensures that an error thrown in handler_terminate/4 will be
shown after the error from handler_call/6, in the expected order.

As we already call WebSocketHandler:terminate/3, this should
fix issue #23.
2011-07-07 17:50:46 +02:00
Loïc Hoguin
108a491f55 Add documentation for the public interface.
This is probably not perfect yet but it should be better than
nothing. We'll improve things with feedback received from the
many users.
2011-07-06 17:42:20 +02:00
Steven Gravell
bebe3dc5d2 do not send ports 80 and 443 - browsers get mad
Browsers get mad that the returned location address is not the same
as what they sent, since the :(80|443) is stripped.

Add a simple eunit test due to existing ct websockets tests not
covering this case.
2011-06-27 15:25:30 +01:00
Loïc Hoguin
648921b8cf Add hibernate support for websockets.
Return {ok, Req, State, hibernate}
or {reply, Data, Req, State, hibernate} to hibernate the websocket
process and save up memory and CPU. You should hibernate processes
that will receive few messages. So probably most of them.
2011-06-06 18:15:36 +02:00
Loïc Hoguin
2fa1e53928 Compile the binary match pattern for websockets only once. 2011-06-06 13:48:41 +02:00
Loïc Hoguin
3cfdf46e97 Remove a binary warning from websocket_data by removing a byte_size call. 2011-05-31 12:48:59 +02:00
Loïc Hoguin
ad2e905a81 Send a meaningful error to error_logger on websocket handler crashes.
Same as commit 4c4030a792 but for websockets.
See also issue #13 on github.
2011-05-27 12:32:02 +02:00
Loïc Hoguin
3e55cb62c9 Refresh the type specifications.
Following discussions on #erlounge.

Also fixes compilation in R14B03 and fixes a few underspecs
dialyzer warnings.
2011-05-25 23:02:40 +02:00
Loïc Hoguin
29e71cf4da Switch the HTTP protocol to use binary packets instead of lists.
The server now does a single recv (or more, but only if needed)
which is then sent to erlang:decode_packet/3 multiple times. Since
most requests are smaller than the default MTU on many platforms,
we benefit from this greatly.

In the case of requests with a body, the server usually read at
least part of the body on the first recv. This is bufferized
properly and used when later retrieving the body.

In the case of pipelined requests, we can end up reading many
requests in a single recv, which are then handled properly using
only the buffer containing the received data.
2011-05-05 14:03:39 +02:00
Loïc Hoguin
6c1f73c53c Add cowboy_http_req:port/1.
Returns the port given in the Host header if present,
otherwise the default port of 443 for HTTPS and 80 for HTTP
is returned.
2011-05-04 12:52:13 +02:00
Loïc Hoguin
e8286e18e6 Remove the include/types.hrl file. 2011-04-18 13:56:38 +02:00
Loïc Hoguin
cb60d18e82 Initial draft-hixie-thewebsocketprotocol-76 support. 2011-04-14 21:21:17 +02:00