<feed xmlns='http://www.w3.org/2005/Atom'>
<title>cowboy.git/test/ws_SUITE_data, branch master</title>
<subtitle>Small, fast, modern HTTP server for Erlang/OTP.
</subtitle>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/'/>
<entry>
<title>New data delivery mechanism for HTTP/2+ Websocket</title>
<updated>2025-09-15T11:09:23+00:00</updated>
<author>
<name>Loïc Hoguin</name>
<email>essen@ninenines.eu</email>
</author>
<published>2025-08-21T16:09:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=8da6ca11e8ea4e93def78bd0299decd6f409bc43'/>
<id>8da6ca11e8ea4e93def78bd0299decd6f409bc43</id>
<content type='text'>
A new data_delivery mechanism called 'relay' has been added.
It bypasses stream handlers (and the buffering in cowboy_stream_h)
and sends the data directly to the process implementing
Websocket (and should work for other similar protocols
like HTTP/2 WebTransport).

Flow control in HTTP/2 is maintained in a simpler way,
via a configured flow value that is used to maintain
the window to a reasonable value when data is received.

The 'relay' data_delivery has been implemented for both
HTTP/2 and HTTP/3. It has not been implemented for HTTP/1.1
since switching protocol there overrides the connection process.

HTTP/2 Websocket is now better tested.

A bug was fixed with the 'stream_handlers' data_delivery
where active mode would not be reenabled if it was disabled
at some point.

The Websocket performance suite has been updated to
include tests that do not use Gun. Websocket modules
used by the performance suite use the 'relay' data_delivery
now. Performance is improved significantly with 'relay',
between 10% and 20% faster. HTTP/2 Websocket performance
is not on par with HTTP/1.1 still, but the remaining
difference is thought to be from the HTTP/2 overhead and
flow control.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A new data_delivery mechanism called 'relay' has been added.
It bypasses stream handlers (and the buffering in cowboy_stream_h)
and sends the data directly to the process implementing
Websocket (and should work for other similar protocols
like HTTP/2 WebTransport).

Flow control in HTTP/2 is maintained in a simpler way,
via a configured flow value that is used to maintain
the window to a reasonable value when data is received.

The 'relay' data_delivery has been implemented for both
HTTP/2 and HTTP/3. It has not been implemented for HTTP/1.1
since switching protocol there overrides the connection process.

HTTP/2 Websocket is now better tested.

A bug was fixed with the 'stream_handlers' data_delivery
where active mode would not be reenabled if it was disabled
at some point.

The Websocket performance suite has been updated to
include tests that do not use Gun. Websocket modules
used by the performance suite use the 'relay' data_delivery
now. Performance is improved significantly with 'relay',
between 10% and 20% faster. HTTP/2 Websocket performance
is not on par with HTTP/1.1 still, but the remaining
difference is thought to be from the HTTP/2 overhead and
flow control.
</pre>
</div>
</content>
</entry>
<entry>
<title>Websocket: Also apply max_frame_size limit to decompressed data</title>
<updated>2025-01-22T14:20:20+00:00</updated>
<author>
<name>Loïc Hoguin</name>
<email>essen@ninenines.eu</email>
</author>
<published>2025-01-22T11:30:27+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=7f739cad6de9403391391b5811ac4a4af31e4688'/>
<id>7f739cad6de9403391391b5811ac4a4af31e4688</id>
<content type='text'>
Before this commit frames could "cheat" by compressing data
below the limit which would get expanded above the limit.
Now Cowboy will stop decompressing data when the limit is
reached.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before this commit frames could "cheat" by compressing data
below the limit which would get expanded above the limit.
Now Cowboy will stop decompressing data when the limit is
reached.
</pre>
</div>
</content>
</entry>
<entry>
<title>Document the commands based Websocket interface</title>
<updated>2019-10-06T14:51:27+00:00</updated>
<author>
<name>Loïc Hoguin</name>
<email>essen@ninenines.eu</email>
</author>
<published>2019-10-06T14:51:27+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=3977f2b96fb8cc2164bfe28ee094b3e661a2fad9'/>
<id>3977f2b96fb8cc2164bfe28ee094b3e661a2fad9</id>
<content type='text'>
The old interface with ok|reply|stop tuples is deprecated.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The old interface with ok|reply|stop tuples is deprecated.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't run long test suites by default</title>
<updated>2018-11-20T12:23:59+00:00</updated>
<author>
<name>Loïc Hoguin</name>
<email>essen@ninenines.eu</email>
</author>
<published>2018-11-20T12:23:59+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=7b5da290199fa0d668b8d9d8267e188b66da1eb3'/>
<id>7b5da290199fa0d668b8d9d8267e188b66da1eb3</id>
<content type='text'>
The examples test suite is only useful once in a while
in order to know whether examples were broken, for example
before issuing a release.

The new ws_autobahn test suite isolates the autobahn test
suite so that it can be ignored by default. It's only
useful to run it when working on the Websocket code or
before issuing a release.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The examples test suite is only useful once in a while
in order to know whether examples were broken, for example
before issuing a release.

The new ws_autobahn test suite isolates the autobahn test
suite so that it can be ignored by default. It's only
useful to run it when working on the Websocket code or
before issuing a release.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add max_frame_size option for websocket handlers</title>
<updated>2018-03-28T14:58:02+00:00</updated>
<author>
<name>Kirill Kinduk</name>
<email>evilbluebeaver@gmail.com</email>
</author>
<published>2017-08-25T09:08:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=4c34774b7eb787e37892399f2daddba68ec277e3'/>
<id>4c34774b7eb787e37892399f2daddba68ec277e3</id>
<content type='text'>
Option allows to limit a frame by size before decoding its payload.

LH: I have added a test for when the limit is reached on a nofin
fragmented frame (the last commit addressed that case but it had
no test). I have fixed formatting and other, and changed the
default value to infinity since it might otherwise be incompatible
with existing code. I also added documentation and a bunch of other
minor changes.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Option allows to limit a frame by size before decoding its payload.

LH: I have added a test for when the limit is reached on a nofin
fragmented frame (the last commit addressed that case but it had
no test). I have fixed formatting and other, and changed the
default value to infinity since it might otherwise be incompatible
with existing code. I also added documentation and a bunch of other
minor changes.
</pre>
</div>
</content>
</entry>
<entry>
<title>Allow passing options to sub protocols</title>
<updated>2017-02-18T17:26:20+00:00</updated>
<author>
<name>Loïc Hoguin</name>
<email>essen@ninenines.eu</email>
</author>
<published>2017-02-18T17:26:20+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=a45813c60f0f983a24ea29d491b37f0590fdd087'/>
<id>a45813c60f0f983a24ea29d491b37f0590fdd087</id>
<content type='text'>
Before this commit we had an issue where configuring a
Websocket connection was simply not possible without
doing magic, adding callbacks or extra return values.
The init/2 function only allowed setting hibernate
and timeout options.

After this commit, when switching to a different
type of handler you can either return

  {module, Req, State}

or

  {module, Req, State, Opts}

where Opts is any value (as far as the sub protocol
interface is concerned) and is ultimately checked
by the custom handlers.

A large protocol like Websocket would accept only
a map there, with many different options, while a
small interface like loop handlers would allow
passing hibernate and nothing else.

For Websocket, hibernate must be set from the
websocket_init/1 callback, because init/2 executes
in a separate process.

Sub protocols now have two callbacks: one with the
Opts value, one without.

The loop handler code was largely reworked and
simplified. It does not need to manage a timeout
or read from the socket anymore, it's the job of
the protocol code. A lot of unnecessary stuff was
therefore removed.

Websocket compression must now be enabled from
the handler options instead of per listener. This
means that a project can have two separate Websocket
handlers with different options. Compression is
still disabled by default, and the idle_timeout
value was changed from inifnity to 60000 (60 seconds),
as that's safer and is also a good value for mobile
devices.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before this commit we had an issue where configuring a
Websocket connection was simply not possible without
doing magic, adding callbacks or extra return values.
The init/2 function only allowed setting hibernate
and timeout options.

After this commit, when switching to a different
type of handler you can either return

  {module, Req, State}

or

  {module, Req, State, Opts}

where Opts is any value (as far as the sub protocol
interface is concerned) and is ultimately checked
by the custom handlers.

A large protocol like Websocket would accept only
a map there, with many different options, while a
small interface like loop handlers would allow
passing hibernate and nothing else.

For Websocket, hibernate must be set from the
websocket_init/1 callback, because init/2 executes
in a separate process.

Sub protocols now have two callbacks: one with the
Opts value, one without.

The loop handler code was largely reworked and
simplified. It does not need to manage a timeout
or read from the socket anymore, it's the job of
the protocol code. A lot of unnecessary stuff was
therefore removed.

Websocket compression must now be enabled from
the handler options instead of per listener. This
means that a project can have two separate Websocket
handlers with different options. Compression is
still disabled by default, and the idle_timeout
value was changed from inifnity to 60000 (60 seconds),
as that's safer and is also a good value for mobile
devices.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove Req from the Websocket interface</title>
<updated>2016-08-12T17:27:23+00:00</updated>
<author>
<name>Loïc Hoguin</name>
<email>essen@ninenines.eu</email>
</author>
<published>2016-08-12T17:27:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=d1b65a67cf093160c383071ef1bb40b0fc096d88'/>
<id>d1b65a67cf093160c383071ef1bb40b0fc096d88</id>
<content type='text'>
After the switch to Websocket, we are no longer in a request/response
scenario, therefore a lot of the cowboy_req functions do not apply
anymore.

Any data required from the request will need to be taken from Req
in init/2 and saved in the handler's state.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
After the switch to Websocket, we are no longer in a request/response
scenario, therefore a lot of the cowboy_req functions do not apply
anymore.

Any data required from the request will need to be taken from Req
in init/2 and saved in the handler's state.
</pre>
</div>
</content>
</entry>
<entry>
<title>send resp_headers with websocket responses</title>
<updated>2016-06-27T17:33:25+00:00</updated>
<author>
<name>Cameron Bytheway</name>
<email>bytheway.cameron@gmail.com</email>
</author>
<published>2016-06-25T01:34:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=e09a85680540029df22001073f73b77eec67773d'/>
<id>e09a85680540029df22001073f73b77eec67773d</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Initial commit with connection/streams</title>
<updated>2016-03-05T19:20:42+00:00</updated>
<author>
<name>Loïc Hoguin</name>
<email>essen@ninenines.eu</email>
</author>
<published>2016-02-10T16:28:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=b370442a6352c5acb13b88e135c32ca1720095bd'/>
<id>b370442a6352c5acb13b88e135c32ca1720095bd</id>
<content type='text'>
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!
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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!
</pre>
</div>
</content>
</entry>
<entry>
<title>Improve handler interface and documentation</title>
<updated>2014-09-30T17:12:13+00:00</updated>
<author>
<name>Loïc Hoguin</name>
<email>essen@ninenines.eu</email>
</author>
<published>2014-09-30T17:12:13+00:00</published>
<link rel='alternate' type='text/html' href='http://git.ninenines.eu/cowboy.git/commit/?id=0dc063ab7d94edb37c61f821b5d8e4c2da7f8ff1'/>
<id>0dc063ab7d94edb37c61f821b5d8e4c2da7f8ff1</id>
<content type='text'>
This change simplifies a little more the sub protocols mechanism.
Aliases have been removed. The renaming of loop handlers as long
polling handlers has been reverted.

Plain HTTP handlers now simply do their work in the init/2
callback. There is no specific code for them.

Loop handlers now follow the same return value as Websocket,
they use ok to continue and shutdown to stop.

Terminate reasons for all handler types have been documented.
The terminate callback is now appropriately called in all cases
(or should be).

Behaviors for all handler types have been moved in the module
that implement them. This means that cowboy_handler replaces
the cowboy_http_handler behavior, and similarly cowboy_loop
replaces cowboy_loop_handler, cowboy_websocket replaces
cowboy_websocket_handler. Finally cowboy_rest now has the
start of a behavior in it and will have the full list of
optional callbacks defined once Erlang 18.0 gets released.

The guide has been reorganized and should be easier to follow.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change simplifies a little more the sub protocols mechanism.
Aliases have been removed. The renaming of loop handlers as long
polling handlers has been reverted.

Plain HTTP handlers now simply do their work in the init/2
callback. There is no specific code for them.

Loop handlers now follow the same return value as Websocket,
they use ok to continue and shutdown to stop.

Terminate reasons for all handler types have been documented.
The terminate callback is now appropriately called in all cases
(or should be).

Behaviors for all handler types have been moved in the module
that implement them. This means that cowboy_handler replaces
the cowboy_http_handler behavior, and similarly cowboy_loop
replaces cowboy_loop_handler, cowboy_websocket replaces
cowboy_websocket_handler. Finally cowboy_rest now has the
start of a behavior in it and will have the full list of
optional callbacks defined once Erlang 18.0 gets released.

The guide has been reorganized and should be easier to follow.
</pre>
</div>
</content>
</entry>
</feed>
