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

652 commits

Author SHA1 Message Date
Fred Hebert
b10b34a8f2 Support ad-hoc keep-alive for HTTP/1.0 Clients
Only go for keep-alive if they submit a 'connection: keep-alive' header
in the request, keep behaviour the same otherwise.

The new RFC 7230 (http://tools.ietf.org/html/rfc7230#section-6.3)
states:

    If the received protocol is HTTP/1.0, the "keep-alive" connection
    option is present, the recipient is not a proxy, and the recipient
    wishes to honor the HTTP/1.0 "keep-alive" mechanism, the
    connection will persist after the current response;

Even though clients are discouraged from doing so in Appendix A.1.2
(http://tools.ietf.org/html/rfc7230#appendix-A.1.2)
2014-07-14 10:11:03 -04:00
Loïc Hoguin
9980348a1c Remove deprecated body reading interface 2014-07-12 15:42:45 +02:00
Loïc Hoguin
e2b5c21443 Drop R15 support 2014-07-12 14:19:29 +02:00
Loïc Hoguin
97a3108576 Reply with 400 on header parsing crash
This is a first step to improve the HTTP status codes returned
by Cowboy on crashes. We will tweak it over time.

Also fixes a small bug where two replies may have been sent
when using loop handlers under rare conditions.
2014-07-12 12:09:43 +02:00
Loïc Hoguin
7f179f377f Add failing test of chaining SPDY frames 2014-07-07 17:18:14 +02:00
Loïc Hoguin
4eee573700 Return 422 instead of 400 when AcceptResource returns false
422 is undefined for HTTP and interpreted as 400.
2014-06-30 17:49:36 +02:00
Drew Varner
6ed25fd60b Allow users to pass a raw binary() as the expires header. 2014-06-10 00:12:26 +02:00
Loïc Hoguin
0c37925642 Add request body reading options
The options were added to allow developers to fix timeout
issues when reading large bodies. It is also a cleaner and
easier to extend interface.

This commit deprecates the functions init_stream, stream_body
and skip_body which are no longer needed. They will be removed
in 1.0.

The body function can now take an additional argument that is a
list of options. The body_qs, part and part_body functions can
too and simply pass this argument down to the body call.

There are options for disabling the automatic continue reply,
setting a maximum length to be returned (soft limit), setting
the read length and read timeout, and setting the transfer and
content decode functions.

The return value of the body and body_qs have changed slightly.
The body function now works similarly to the part_body function,
in that it returns either an ok or a more tuple depending on
whether there is additional data to be read. The body_qs function
can return a badlength tuple if the body is too big. The default
size has been increased from 16KB to 64KB.

The default read length and timeout have been tweaked and vary
depending on the function called.

The body function will now adequately process chunked bodies,
which means that the body_qs function will too. But this means
that the behavior has changed slightly and your code should be
tested properly when updating your code.

The body and body_qs still accept a length as first argument
for compatibility purpose with older code. Note that this form
is deprecated and will be removed in 1.0. The part and part_body
function, being new and never having been in a release yet, have
this form completely removed in this commit.

Again, while most code should work as-is, you should make sure
that it actually does before pushing this to production.
2014-06-02 23:09:43 +02:00
Loïc Hoguin
c966076bbe Add a test for multipart over chunked transfer-encoding 2014-04-26 17:34:56 +02:00
Loïc Hoguin
980342f73c Make loop handlers work with SPDY
Adds a loop_handler test suite that runs all tests under HTTP, HTTPS,
SPDY each with and without the compress option enabled.

Fixes output filtering that used to filter more than it should have.
This forces us to parse the string sent by the emulator, which means
it's probably not perfect yet. But it should at least not hide errors
we want to see.

Fix a crash in the output filtering code that entirely disabled
output. Now when there is a crash the normal tty output is restored.

Handlers are now in test/handlers/ as they can be reused between
suites.

Only generate a single certificate for the whole ct run to speed
things up when we got many different test groups each needing
certificates.
2014-04-26 13:46:55 +02:00
Loïc Hoguin
a3f7f68e30 Fix two issues where listeners didn't get stopped properly 2014-04-24 14:55:58 +02: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
75218c4be0 Silence expected test error reports from the console output
The errors are still logged by common_test to the report it creates.
The process that is going to crash has to call cowboy_error_h:ignore/3
with the MFA where the crash is expected to occur for it to be ignored.
Gun retry failures are also ignored. Only unexpected crashes are printed.
2014-04-21 21:24:43 +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
806cde9ace Cleanup the configuration handling in http_SUITE 2014-04-17 19:15:39 +02:00
Loïc Hoguin
71b8316b0d Fix application start order in tests, gun depends on cowlib 2014-04-11 14:34:35 +02:00
Loïc Hoguin
a01f992ffb Simplify the SPDY suite using the new Gun interface 2014-03-25 13:01:23 +01:00
Loïc Hoguin
704f61c9d1 Remove cowboy_client; use gun for the HTTP test suite 2014-03-24 14:25:09 +01:00
Loïc Hoguin
903594bb87 Update copyright years 2014-02-06 19:57:23 +01:00
Loïc Hoguin
917cf99e10 Add and document the new multipart code
The old undocumented API is removed entirely.

While a documentation exists for the new API, it will not
be considered set in stone until further testing has been
performed, and a file upload example has been added.

The new API should be a little more efficient than the
old API, especially with smaller messages.
2014-02-06 19:36:25 +01:00
Loïc Hoguin
b1fc7b1a9f Nicer error when NPN isn't available 2013-12-28 17:49:37 +01:00
Loïc Hoguin
4efe014a2a Fix a small typo in a test 2013-12-28 17:34:59 +01:00
Loïc Hoguin
0a439d0f03 Fix the SPDY suite for R15 2013-12-28 17:20:08 +01:00
James Fish
1c474af8ee Fix loop handler keepalive race condition
Previously if a loop handler received the timeout message from a
previous request on the same connection the socket would be set to
{active, once} incorrectly - when a socket packet was already in the
message queue. This second packet would not be added to the buffer
before a Handler:info/3 call if a user message was in the message
queue before both socket packets.
2013-11-18 23:19:37 +00:00
Adrian Roe
c2e946708e Add a workaround to disable chunked transfer-encoding
This is an undocumented workaround to disable chunks when using HTTP/1.1.
It can be used when the client advertises itself as HTTP/1.1 despite not
understanding the chunked transfer-encoding.

Usage can be found looking at the test for it. When activated, Cowboy
will still advertise itself as HTTP/1.1, but will send the body the same
way it would if it was HTTP/1.0.
2013-11-08 21:56:37 +01:00
Loïc Hoguin
6672ea0415 Review, improve and document the static files handler
Changes include:

 *  Much simplified route configuration.

 *  Etag generation is now enabled by default.

 *  Web mimetypes are now detected by default. A bigger list of
    mimetypes can be detected without any additional library.

 *  Mimetypes can no longer be specified as a list. Copying this
    list for new connections is too costy. You can easily convert
    it into a function and pass that function to the handler instead.

 *  You can however specify a single hardcoded mimetype. Mostly
    useful when serving a single file, like an index.html file,
    to avoid extra operations.

 *  Specifying a path as a list of tokens is not possible anymore.
    Use either a binary or a string.

 *  Using a private directory will not work if the application
    was not started properly. Cowboy will not attempt to find
    the location of this directory if the VM doesn't know it,
    as this caused issues in some setups.

 *  Overall the code has been much simplified and clarified,
    and of course has now been documented.
2013-11-02 14:41:46 +01:00
Loïc Hoguin
bbe42d9bc5 Fix value for header content-encoding in a test
Not that it matters for the test, but still.
2013-09-09 16:28:37 +02: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
Loïc Hoguin
67410731e0 Merge branch 'ipv6-literal' of git://github.com/yamt/cowboy 2013-09-02 20:05:03 +02:00
YAMAMOTO Takashi
d2adbf3de6 add some tests for Host header parser 2013-09-03 02:59:12 +09:00
Loïc Hoguin
9eab26d835 Add request body support for SPDY
And various other improvements following the addition of two tests.

New dependency cowlib that will gradually receive most of the parse
code from SPDY but also HTTP and its headers.
2013-09-02 19:14:28 +02:00
Loïc Hoguin
d68b3de9d9 Use gun to test the SPDY implementation in Cowboy 2013-08-31 18:39:49 +02:00
Loïc Hoguin
ddefa33a38 Merge branch 'fix/websocket-inflate-unmask' of git://github.com/soundrop/cowboy 2013-07-12 21:57:27 +02:00
Loïc Hoguin
f66a6fc57a Merge branch 'fix-chunked-req' of git://github.com/fishcakez/cowboy 2013-07-12 18:51:28 +02:00
James Fish
f0cc2d01e6 Fix decoding of chunked body.
Previously cowboy_http:te_chunked/2 would enter an incorrect state if
it tried to parse an incomplete chunk when the length was known from the
partial chunk.

Previosuly cowboy_http:te_chunked/2 expected the trailing "\r\n" to
always be present if chunk body was present in the buffer. This is not
guaranteed and so this commit accommodates that situation.
2013-07-05 22:45:18 +01:00
Ali Sabil
b0d0cabf12 Add failing tests for the websocket deflate support 2013-07-02 13:46:21 +02:00
Loïc Hoguin
39caf34fe3 Merge branch 'fix/http-tests-get-mtu' of git://github.com/soundrop/cowboy 2013-06-29 21:54:18 +02:00
Loïc Hoguin
fdf2bc93f6 Add asn1 to the list of applications to be started for SSL
Required since R16B01. And apparently needed in some cases before.
2013-06-20 16:01:58 +02:00
Ali Sabil
a63faff35e Add support for the webkit deflate frame extension 2013-06-20 13:09:13 +02:00
Ali Sabil
240533939c Use ct_helper for retrieving the loopack interface MTU 2013-06-13 11:47:24 +02:00
Ali Sabil
809dc32339 Improve the detection of localhost interfaces for the HTTP test suite 2013-06-10 09:53:32 +02:00
Ali Sabil
fdd67b72a3 Fix the reading of the localhost MTU in the HTTP tests
Sometimes the localhost interface has a different name from "lo",
this fix adds a helper function to read the MTU value when the
interface name starts with "lo".
2013-06-07 12:01:01 +02:00
Loïc Hoguin
1fc69977da Add sendfile support to SPDY, enabling cowboy_static use 2013-06-03 19:10:03 +02:00
Loïc Hoguin
e50f7e4086 Move static files creation into ct_helper 2013-06-03 17:20:54 +02:00
Loïc Hoguin
4fde6cba94 In content-types, the charset parameter is converted to lowercase
We know this specific parameter is case insensitive so we
automatically lowercase it to make things simpler to the
developer.
2013-05-31 18:38:43 +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
934393a168 Make the return value of AcceptResource callback consistent 2013-05-16 15:14:11 +02:00
Loïc Hoguin
6e33274c85 Update Ranch to 0.8.2 and use ct_helper for testing SSL 2013-05-01 18:30:00 +02:00
Loïc Hoguin
83e8ebb9ff Merge branch 'chunked-set-resp-body-fun' of git://github.com/fishcakez/cowboy 2013-04-28 16:08:36 +02:00