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

50 commits

Author SHA1 Message Date
Loïc Hoguin
67df6fedae
Add cowboy:get_env/2,3 2024-01-05 12:31:48 +01:00
Viktor Söderqvist
7400b04b02
Remove next_protocols_advertised 2023-12-19 11:57:54 +01:00
Loïc Hoguin
473e3fb82b
Improve a few types, including cowboy_req:req() 2018-10-31 14:11:45 +01:00
Loïc Hoguin
3310849115
Simplify a case clause 2018-10-26 10:16:15 +02:00
Loïc Hoguin
d394eb7256
Fix ranch:start_tls when transport options are a map 2018-10-02 10:03:09 +02:00
Loïc Hoguin
06a3a93de0
Update Ranch to 1.6.1 2018-08-13 15:07:59 +02:00
Loïc Hoguin
a76c32db5e
Introduce undocumented option logger
This commit reworks the logging that Cowboy does via
error_logger to make the module that will do the actual
logging configurable.

The logger module interface must be the same as logger
and lager: a separate function per log level with the
same log levels they support.

The default behavior remains to call error_logger,
although some messages were downgraded to warnings
instead of errors. Since error_logger only supports
three different log levels, some messages may get
downgraded/upgraded depending on what the original
log level was to make them compatible with error_logger.

The {log, Level, Format, Args} command was also
added to stream handlers. Stream handlers should
use this command to log messages because it allows
writing a stream handler to intercept some of those
messages and extract information or block them as
necessary.

The logger option only applies to Cowboy itself,
not to the messages Ranch logs, so more work remains
to be done in that area.
2018-06-28 17:10:18 +02:00
Loïc Hoguin
9317751cb3
Fix cowboy:set_env when the env value is missing 2017-10-02 16:19:13 +02:00
Loïc Hoguin
6f7b59886e
Remove NumAcceptors argument from start_clear/tls
They are now cowboy:start_clear/3 and cowboy:start_tls/3.
The NumAcceptors argument can be specified via the
num_acceptor transport option. Ranch has been updated
to 1.4.0 to that effect.
2017-06-07 15:15:54 +02:00
Alexandre Snarskii
304e3efbf8
make set_env working with maps. 2017-05-07 18:39:47 +02:00
Loïc Hoguin
0f8452cafa
Add support for multiple stream handlers
The stream handlers can be specified using the protocol
option 'stream_handlers'. It defaults to [cowboy_stream_h].

The cowboy_stream_h module currently does not forward the
calls to further stream handlers. It feels like an edge
case; usually we'd want to put our own handlers between
the protocol code and the request process. I am therefore
going to focus on other things for now.

The various types and specifications for stream handlers
have been updated and the cowboy_stream module can now
be safely used as a behavior. The interface might change
a little more, though.

This commit does not include tests or documentation.
They will follow separately.
2017-01-16 14:36:33 +01:00
Loïc Hoguin
43adacc760
Welcome to 2017 2017-01-02 19:36:36 +01:00
Loïc Hoguin
e10daf39fa
Numerous Dialyzer fixes 2017-01-02 16:47:16 +01:00
Loïc Hoguin
3a057683af Add a lot of todos 2016-08-10 11:52:41 +02:00
Loïc Hoguin
ae0dd61673 Add tests for responses and request body reading
This is a large commit. The cowboy_req interface has largely
changed, and will change a little more. It's possible that
some examples or tests have not been converted to the new
interface yet. The documentation has not yet been updated.
All of this will be fixed in smaller subsequent commits.

Gotta start somewhere...
2016-08-10 11:49:31 +02:00
Loïc Hoguin
d19134b02e Use the correct process type for clear connections 2016-06-06 16:13:51 +02:00
Loïc Hoguin
7bdd710849 Completely remove SPDY 2016-03-06 17:48:35 +01: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
a6f75aa3dc Add HTTP/2 support preview
This commit is not only an early preview of HTTP/2, it is an
early preview of the new Cowboy architecture that will be
presented tomorrow in my talk. If you have found it before
the talk, great! It's not complete so you better go watch
the talk anyway.
2015-06-11 17:04:21 +02:00
Loïc Hoguin
aa4d86b81f Remove the onrequest hook
It was redundant with middlewares. Allows us to save a few operations
for every incoming requests.
2014-09-24 14:39:17 +03:00
Loïc Hoguin
f1c3b6d76f Breaking update of the cowboy_req interface
Simplify the interface for most cowboy_req functions. They all return
a single value except the four body reading functions. The reply functions
now only return a Req value.

Access functions do not return a Req anymore.

Functions that used to cache results do not have a cache anymore.

The interface for accessing query string and cookies has therefore
been changed.

There are now three query string functions: qs/1 provides access
to the raw query string value; parse_qs/1 returns the query string
as a list of key/values; match_qs/2 returns a map containing the
values requested in the second argument, after applying constraints
and default value.

Similarly, there are two cookie functions: parse_cookies/1 and
match_cookies/2. More match functions will be added in future commits.

None of the functions return an error tuple anymore. It either works
or crashes. Cowboy will attempt to provide an appropriate status code
in the response of crashed handlers.

As a result, the content decode function has its return value changed
to a simple binary, and the body reading functions only return on success.
2014-09-23 16:43:29 +03:00
Loïc Hoguin
17af50812c Remove outdated comments, all edoc, plus a few minor tweaks 2014-03-26 19:05:59 +01:00
Sina Samavati
b72c420d58 Fix stop_listener/1 spec 2014-02-16 00:16:58 +03:30
Loïc Hoguin
903594bb87 Update copyright years 2014-02-06 19:57:23 +01:00
Radosław Szymczyszyn
e4f407e426 Fix cowboy:start_http/https/spdy typespecs 2013-06-02 00:40:22 +02:00
Loïc Hoguin
9a2d35c2e8 Add experimental and incomplete SPDY support
The SPDY connection processes are also supervisors.

Missing:
 *  sendfile support
 *  request body reading support
2013-05-30 20:21:01 +02:00
Loïc Hoguin
0e0ec7b120 Use the ranch_ssl:opts() type in cowboy:start_https/4 spec 2013-05-16 19:17:01 +02:00
Loïc Hoguin
e4bb2ffc77 Use the ranch_tcp:opts() type in cowboy:start_http/4 spec 2013-05-16 19:16:13 +02:00
Loïc Hoguin
bb89bf6f8d Use the type ranch:ref() instead of any() where applicable 2013-05-16 19:13:36 +02:00
Loïc Hoguin
6d1344319a Add cowboy_protocol:opts() type
Should improve the detection of wrong protocol options.
2013-05-16 17:56:45 +02:00
Loïc Hoguin
1d413ea51b Move cowboy_protocol:onresponse_fun() to cowboy:onresponse_fun() 2013-05-16 17:01:38 +02:00
Loïc Hoguin
488dcc967b Move cowboy_protocol:onrequest_fun() to cowboy:onrequest_fun() 2013-05-16 16:52:20 +02:00
Loïc Hoguin
df73a4d0a5 Move cowboy_http:status() to cowboy:http_status() 2013-05-16 16:29:24 +02:00
Loïc Hoguin
f8a7856127 Move cowboy_http:headers() to cowboy:http_headers() 2013-05-16 16:16:32 +02:00
Loïc Hoguin
c0c333e41b Move cowboy_http:version() to cowboy:http_version() 2013-05-16 16:06:52 +02:00
Loïc Hoguin
b2ffff9bec Add cowboy:set_env/3 2013-02-20 12:14:21 +01:00
Loïc Hoguin
54063de2ff Hello 2013 2013-01-04 15:10:03 +01:00
Loïc Hoguin
9e2622becb Rename cowboy_http_protocol to cowboy_protocol 2012-08-27 12:58:04 +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
Loïc Hoguin
8363e8995a Small updates to the ROADMAP and doc comments 2012-05-21 08:49:22 +02:00
Loïc Hoguin
e5aef5c1d7 Add cowboy:get_protocol_options/1 and cowboy_set_protocol_options/2
This allows any application to upgrade the protocol options without
having to restart the listener. This is most useful to update the
dispatch list of HTTP servers, for example.

The upgrade is done at the acceptor level, meaning only new connections
receive the new protocol options.
2012-01-31 08:49:15 +01:00
Loïc Hoguin
e550ba7cd3 Add cowboy:accept_ack/1 for a cleaner handling of the shoot message 2011-12-15 20:19:02 +01:00
Jesper Louis Andersen
a800425131 Add cowboy:child_spec/6
This new exported function returns a Child Spec suitable for embedding
cowboy in another applications supervisor structure. While here,
implement `start_listener/6` in terms of it.
2011-10-10 08:18:26 +02:00
Loïc Hoguin
56369d5c1a Introduce cowboy_listener for managing a listener
Currently only supports limiting the maximum number of
connections by managing connection pools.
2011-08-10 16:43:59 +02:00
Loïc Hoguin
d363f91410 Fail fast when a wrong type is given to API functions
Idea given by bfrog, fixes issue #34.
2011-07-18 14:21:45 +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
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
a8af32c54b Don't ignore the return values in cowboy:stop_listener/1. 2011-04-03 15:21:29 +02:00
Loïc Hoguin
718baffa3c Make Cowboy an OTP application again, properly this time.
As requested by many people on IRC Cowboy is now a proper OTP application
to support soft code upgrades. It should also be easier to start and stop
listeners now using cowboy:start_listener/6 and cowboy:stop_listener/1.
2011-04-03 00:21:47 +02:00