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

37 commits

Author SHA1 Message Date
Loïc Hoguin
97986df276 Fix Websocket compression
The option for enabling Websocket compression has been
renamed. Previously it was shared with HTTP compression,
now it's specific to Websocket. The new option is named
'websocket_compress'.
2016-08-12 16:56:08 +02:00
Loïc Hoguin
b370442a63 Initial commit with connection/streams
Breaking changes with previous commit. This is a very large change,
and I am giving up on making a single commit that fixes everything.
More commits will follow slowly adding back features, introducing
new tests and fixing the documentation.

This change contains most of the work toward unifying the interface
for handling both HTTP/1.1 and HTTP/2. HTTP/1.1 connections are now
no longer 1 process per connection; instead by default 1 process per
request is also created. This has a number of pros and cons.

Because it has cons, we also allow users to use a lower-level API
that acts on "streams" (requests/responses) directly at the connection
process-level. If performance is a concern, one can always write a
stream handler. The performance in this case will be even greater
than with Cowboy 1, although all the special handlers are unavailable.

When switching to Websocket, after the handler returns from init/2,
Cowboy stops the stream and the Websocket protocol takes over the
connection process. Websocket then calls websocket_init/2 for any
additional initialization such as timers, because the process is
different in init/2 and websocket_*/* functions. This however would
allow us to use websocket_init/2 for sending messages on connect,
instead of sending ourselves a message and be subject to races.
Note that websocket_init/2 is optional.

This is all a big change and while most of the tests pass, some
functionality currently doesn't. SPDY is broken and will be removed
soon in favor of HTTP/2. Automatic compression is currently disabled.
The cowboy_req interface probably still have a few functions that
need to be updated. The docs and examples do not refer the current
functionality anymore.

Everything will be fixed over time. Feedback is more than welcome.
Open a ticket!
2016-03-05 20:20:42 +01:00
Loïc Hoguin
3098986710 Fix autobahn test suite report link when used in CI 2015-07-22 23:57:57 +02:00
Loïc Hoguin
fe5acb20f1 Add autobahn test suite output to the console 2015-07-22 23:05:49 +02:00
Loïc Hoguin
228cebaf04 Add rfc7230 test suite and update others to recent Gun
This is a large commit.

The rfc7230 test suite adds many tests from the RFC7230 document.

Gun has been updated quite a bit recently, which broke the Cowboy
suites. This is now fixed with this commit.

A new hook onfirstrequest has been added. It was very useful during
debugging of the test suites.

The initial process code has changed a little; more changes are
expected with the switch to maps for options.
2015-05-05 19:59:37 +03:00
Loïc Hoguin
90ae31998e Update Cowlib to 1.2.0; adds Websocket permessage-deflate
The Websocket text frames should also be less resource intensive
to validate now, with a binary concatenation avoided.
2015-03-06 01:56:30 +01:00
Loïc Hoguin
5ce4c2bfb4 Unify the init and terminate callbacks
This set of changes is the first step to simplify the
writing of handlers, by removing some extraneous
callbacks and making others optional.

init/3 is now init/2, its first argument being removed.

rest_init/2 and rest_terminate/2 have been removed.

websocket_init/3 and websocket_terminate/3 have been removed.

terminate/3 is now optional. It is called regardless of
the type of handler, including rest and websocket.

The return value of init/2 changed. It now returns
{Mod, Req, Opts} with Mod being either one of the four
handler type or a custom module. It can also return extra
timeout and hibernate options.

The signature for sub protocols has changed, they now
receive these extra timeout and hibernate options.

Loop handlers are now implemented in cowboy_long_polling,
and will be renamed throughout the project in a future commit.
2014-09-26 15:58:44 +03:00
Loïc Hoguin
25a17a2590 Move listener initialization to cowboy_test 2014-04-22 22:50:45 +02:00
Loïc Hoguin
b377eb9805 Start applications directly from the ct hook 2014-04-22 20:52:08 +02:00
Loïc Hoguin
74512fc84c Enable Autobahn Test Suite by default
Includes a variety of small changes that are a first step to
improving the test system heavily.
2014-04-20 22:20:54 +02:00
Loïc Hoguin
903594bb87 Update copyright years 2014-02-06 19:57:23 +01:00
Loïc Hoguin
4a30198f90 Make cowlib a proper dependency
Start moving a few functions from Cowboy into cowlib.
2013-09-04 19:24:54 +02:00
Ali Sabil
b0d0cabf12 Add failing tests for the websocket deflate support 2013-07-02 13:46:21 +02:00
Ali Sabil
a63faff35e Add support for the webkit deflate frame extension 2013-06-20 13:09:13 +02:00
Loïc Hoguin
2e91677723 Reorganize the websocket test suite
We now have the suite specific modules in the data folder.
Compilation is performed by the Makefile instead of ct_run.
2013-04-22 17:03:54 +02:00
Loïc Hoguin
3442acbe35 Run tests in parallel 2013-03-02 16:24:34 +01:00
Loïc Hoguin
0ba06578f2 Use random ports for tests 2013-03-02 14:39:05 +01:00
Loïc Hoguin
a357c49d1b New routing
Ultimately few things change, it's mostly just a nicer syntax and
slightly different expectations. The name of the value `dispatch`
did not change, because the previous dispatch values will now fail
if the code is not updated to using `cowboy_router:compile/1`.

No constraints have been implemented in this commit.
2013-01-28 16:53:09 +01:00
Loïc Hoguin
3b8a1365d1 Do not require inets for running tests anymore 2013-01-22 14:22:28 +01:00
Loïc Hoguin
8d69099508 Improve websocket close handling
We now always send a failure reason (bad protocol, bad encoding, etc.)
unless the closure was initiated by the client and it didn't send a
close code.

We now check that the close frames have a payload that is valid UTF-8,
unless they don't have a payload at all.

We now do not crash the process anymore when bad opcodes are sent, or
when the opcode 0 is sent before fragmentation was initiated.

Overall this makes us closer to full compliance with the RFC.
2013-01-14 16:20:33 +01:00
Loïc Hoguin
71b68d53d9 All frames sent from client to server MUST be masked
Good in theory, but implementations may vary. If something stops
working after this commit we might need some tweaks to support
existing clients.

Please try it and give feedback.
2013-01-12 16:04:35 +01:00
Loïc Hoguin
10e3692fa6 Remove support for Websocket hixie76 draft
It was only used by Safari 5.0.1 and possibly 5.1. Their market share
is dropping as we speak. It was also insecure (disabled in Firefox
for that reason).

This will allow us to make much more efficient and cleaner code for
the rest of the Websocket versions we support (drafts 7 to 17 + RFC),
which are pretty much all versions seen in the wild excluding the
one we're removing here.
2013-01-10 21:58:38 +01:00
Loïc Hoguin
9bfef7c715 Update autobahntestsuite to 0.5.2
Also small mostly insignificant changes to tests.
2013-01-10 19:54:10 +01:00
Loïc Hoguin
54063de2ff Hello 2013 2013-01-04 15:10:03 +01:00
Loïc Hoguin
1b3f510b7e Add middleware support
Middlewares allow customizing the request processing.

All existing Cowboy project are incompatible with this commit.
You need to change `{dispatch, Dispatch}` in the protocol options
to `{env, [{dispatch, Dispatch}]}` to fix your code.
2013-01-03 22:47:51 +01:00
Jeremy Ong
5f122d9fa6 Cancel timer only on websocket_data receives or sends
This commit prevents erlang messages from keeping a websocket connection
alive. Previously, the timer was canceled upon any activity. Now, the
timeout is only canceled when actual data is sent from the client. The
handler_loop_timeout/1 function is called from websocket_data/4 instead
of handler_before_loop/4. It is also called after every successful reply
in handler_call/4.
2012-12-22 18:32:15 +01:00
Loïc Hoguin
6d4e15705f Add {close, StatusCode, Payload} and fix {close, Payload} 2012-12-08 19:11:56 +01:00
Loïc Hoguin
5ef4a15b48 Allow passing the Req and an updated Opts when upgrading protocols 2012-12-03 15:52:09 +01:00
Loïc Hoguin
067958abd2 Add more frame types available in websocket replies
We can now reply empty close, ping and pong frames, or close
frames with a payload.

This means that we can send a frame and then close the connection
in a single operation.

If a close packet is sent, the connection is closed immediately,
even if there was frames that remained to be sent. Cowboy will
silently drop any extra frames in the list given as a reply.
2012-12-02 21:37:24 +01:00
Loïc Hoguin
916bfde1f8 Fix a test that worked intermittently 2012-11-27 17:31:54 +01:00
Loïc Hoguin
09914c4693 Allow websocket handlers to reply more than one frame
Instead of returning {text, Data}, you can now return
[{text, Data}, {text, Data2}, ...].
2012-10-11 21:46:43 +02:00
Loïc Hoguin
aeb86e70c1 Add crypto into the required applications
As suggested by @prof3ta.
2012-10-11 20:13:23 +02:00
Loïc Hoguin
e4124de2c7 Switch to Ranch for connection handling
This is the first of many API incompatible changes.

You have been warned.
2012-08-27 11:50:35 +02:00
Loïc Hoguin
0c2e2224e3 Update version to 0.6.0
Also update the CHANGELOG and copyright years.
2012-05-23 14:53:48 +02:00
Magnus Klaar
0b15ed914d Add support for fragmented websocket messages 2012-04-05 22:02:04 +02:00
Loïc Hoguin
7a68a38e5a Add ct tests for binary websocket frames 2011-12-22 20:19:05 +01:00
Loïc Hoguin
9800348c21 Move the websocket tests in a separate suite 2011-12-22 20:06:58 +01:00