Age | Commit message (Collapse) | Author |
|
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!
|
|
|
|
|
|
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.
|
|
The Websocket text frames should also be less resource intensive
to validate now, with a binary concatenation avoided.
|
|
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.
|
|
|
|
|
|
Includes a variety of small changes that are a first step to
improving the test system heavily.
|
|
|
|
Start moving a few functions from Cowboy into cowlib.
|
|
|
|
|
|
We now have the suite specific modules in the data folder.
Compilation is performed by the Makefile instead of ct_run.
|
|
|
|
|
|
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.
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
Also small mostly insignificant changes to tests.
|
|
|
|
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.
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
Instead of returning {text, Data}, you can now return
[{text, Data}, {text, Data2}, ...].
|
|
As suggested by @prof3ta.
|
|
This is the first of many API incompatible changes.
You have been warned.
|
|
Also update the CHANGELOG and copyright years.
|
|
|
|
|
|
|