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

979 commits

Author SHA1 Message Date
Loïc Hoguin
725bdb9774 HTTP/2: Separate path and query components 2016-06-06 17:28:56 +02:00
Loïc Hoguin
8e9196215d HTTP/2: Handle internal errors 2016-06-06 17:28:35 +02:00
Loïc Hoguin
61e9f29279 HTTP/2: add support for sending files 2016-06-06 17:27:48 +02:00
Loïc Hoguin
7603518ed0 HTTP/1.1: Don't send 500 errors twice
The stream handler is responsible for sending errors.
The protocol should only send errors when no responses
were sent (this might not work yet).
2016-06-06 17:26:13 +02:00
Loïc Hoguin
327e8db623 Report request process crashes 2016-06-06 17:20:30 +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
3969c31824 Fix most remaining HTTP/2 handshake tests
One category of tests involving the SETTINGS ack still fails.
It is probably wise to leave these until more SETTINGS related
tests are written.
2016-03-13 23:14:57 +01:00
Loïc Hoguin
2620d65fde Fix more HTTP/2 handshake test cases 2016-03-13 11:26:26 +01:00
Loïc Hoguin
4e6a4ee53f Add initial HTTP/1.1 Upgrade to HTTP/2
The same edge cases that fail with other handshake methods
also fail here (mostly bad preface/timeouts stuff). In
addition, the HTTP2-Settings header contents are currently
not checked and so the related edge case tests also fail.
2016-03-12 18:25:35 +01:00
Loïc Hoguin
92edad53d2 Add the beginning of the rfc7540 test suite
Currently only testing handshake.

Tests that pass currently involve no request/response.
ALPN and prior knowledge support have some edge cases left to fix.
HTTP/1.1 Upgrade has not been implemented yet.
2016-03-10 23:30:49 +01:00
Loïc Hoguin
0193538dba Fix warnings 2016-03-06 18:09:43 +01: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
Alexey Lebedeff
b290b88a67 Use 'Connection' header only when necessary
Fixes #839 when 'Connection: Keep-Alive' wasn't sent in a HTTP/1.0
response. Now the usage of 'Connection' header is consistent with
current protocol version: when this header is not specified explicitly
in the response, HTTP/1.0 implies 'Connection: close' and HTTP/1.1
implies 'Connection: Keep-Alive'. So if current 'Connection' value
matches the default value of current protocol, we won't state obvious
fact in the response; and vice versa.

Amended to fix and improve tests, and revert the variable name
change from HTTP11Headers to StdHeaders. I think it's still good
to leave it as is because it's not really a standard header for
HTTP/1.0, and it's gone from HTTP/2 entirely.
2015-08-07 12:48:07 +02:00
Loïc Hoguin
e25634cd9d Add optional callbacks
Mostly useful for REST, which has a ton. This is an initial
commit, it still needs to be tested, but it's time to sleep.
2015-07-27 23:58:58 +02:00
Loïc Hoguin
dd1eaee0cd Add spec to silence a Dialyzer warning
Yes I know the function never returns. :-)
2015-07-27 17:58:27 +02:00
Loïc Hoguin
d043148f4a Use map syntax instead of maps:put/3 2015-07-27 17:32:05 +02:00
Loïc Hoguin
ccd786baee Use erlang:monotonic_time instead of os:timestamp
Avoids unnecessary calculations.
2015-07-27 17:31:24 +02:00
Loïc Hoguin
5394d0e08c Merge branch 'master' of https://github.com/jmccaughey/cowboy 2015-07-25 18:03:26 +02:00
Loïc Hoguin
190f698990 Update erlang.mk and remove .app.src
Everything is now directly generated from the Makefile.
Also properly update dependencies.
2015-07-21 17:16:11 +02:00
Loïc Hoguin
341f991d58 Fix compilation error due to previous commit
Ah, conference commits.
2015-06-12 00:33:13 +02: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
jmccaughey
427eb3b622 expect header parses to an atom (continue) 2015-05-29 15:07:22 -07:00
James Fish
2718698895 Exit with exit/1 on handler exception and include class in reason 2015-05-07 18:43:09 +01:00
Loïc Hoguin
1f5b19a0b7 Use the most recent state on error in cowboy_rest 2015-05-06 17:38:35 +03:00
Loïc Hoguin
4aabb67562 Fix a compile error introduced in previous commit 2015-05-06 17:37:20 +03:00
Loïc Hoguin
40fa0b130c Dialyzer fixes in cowboy_clock
This is what I get for merging blindly!
2015-05-06 17:24:55 +03:00
Loïc Hoguin
21632944bb Merge branch 'patch-2' of https://github.com/egobrain/cowboy 2015-05-06 11:34:37 +03:00
Alex Kovalev
817c6ed7c0 added a comment for non-obvious erlang:cancel_timer 2015-05-06 11:27:49 +03:00
Alex Kovalev
f25e452139 fixed cowboy_clock inbox overflow if system clock was changed 2015-05-06 11:27:47 +03: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
Yakov
8fc6906dbb Fix reply/4 spec
There is wrong -spec of reply/4 function 3rd parametr type must be same as [#http_req spec](https://github.com/ninenines/cowboy/blob/master/src/cowboy_req.erl#L140)
2015-02-17 15:31:02 +03:00
Loïc Hoguin
d2205d9ea6 Do not send empty chunks
User code may sometimes send an empty value which gets understood
by the client as being the end of the stream while this was not
intended. Ignoring empty values allow making sure the stream isn't
ended by mistake.
2015-02-16 19:49:01 +01:00
Loïc Hoguin
e74120bee1 Merge branch 'add_spdy_record_field_type' of https://github.com/sile/cowboy 2015-02-16 18:09:43 +01:00
Loïc Hoguin
dc8be8882c Use cow_ws for the Websocket parsing code
Updates Cowlib to 1.1.0
2015-02-16 15:48:04 +01:00
Loïc Hoguin
89c47d3d6e Use cowlib for parsing headers; remove cowboy_http 2015-02-04 16:18:28 +01:00
Loïc Hoguin
3cede06283 Use cowlib master 2015-02-03 18:54:26 +01:00
Loïc Hoguin
41ac668ac7 Add a test with host ending in a dot in the router 2015-02-01 19:34:10 +01:00
Loïc Hoguin
02b1b28178 Discard whitespace at the end of header values early
This is more in line with what RC7230 says, and will allow simplifying
the parsing code of a few headers in cowlib.
2014-12-21 16:23:46 +02:00
Takeru Ohta
c0672b8433 Add typespecs for state record in cowboy_spdy module 2014-12-05 05:05:23 +09:00
Loïc Hoguin
999dc5b7c1 Rename 'halt' to 'stop' for better consistency
Now everywhere in Cowboy when we want to stop something we return
a 'stop' tuple instead of one of the many choices depending on
context that we had before.

This particular change affects middlewares, sub protocols and
REST handlers which were using 'halt' to stop processing.
2014-11-07 20:19:05 +02:00
Loïc Hoguin
8cbd8c1882 Rename 'shutdown' close reason and tuples to 'stop'
The 'shutdown' atom has a specific meaning inside OTP. We are
instead going to use 'stop' which is pretty much the equivalent
of what we actually do. 'shutdown' is now reserved for future
special processes implementation.
2014-11-07 19:22:36 +02:00
Loïc Hoguin
903f6f4c7d Update erlang.mk 2014-11-07 14:25:34 +02:00
Loïc Hoguin
5ff3fdd91e Update version to 2.0.0-pre.1 2014-10-04 17:01:43 +03:00
Loïc Hoguin
21d9ebe33b Reverse the order of arguments of match_* functions
Wasn't following the same order as the rest of the module.
2014-10-04 13:21:16 +03:00
Loïc Hoguin
4bc8e330fa Remove the REST known_content_type callback
This callback was simply useless.
2014-10-03 18:52:14 +03:00
Loïc Hoguin
bee5ca852b Replace some /binary to /bits in binary pattern matching
We don't need the extra check for multiple of 8 bits.
2014-10-03 18:25:29 +03:00
Loïc Hoguin
8e17d492b3 Fix a compile issue caused by a warning 2014-10-03 18:11:29 +03:00
Loïc Hoguin
403895a641 Fix two edge cases when the request-line provided is invalid 2014-10-03 17:19:04 +03:00