0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 12:40:25 +00:00
Commit graph

1125 commits

Author SHA1 Message Date
Loïc Hoguin
119d52295f Add documentation for cowboy_spdy 2013-11-14 16:46:31 +01:00
Loïc Hoguin
5d27d4d175 Properly send 201 on PUT requests when resource didn't exist
Regardless of whether a location header has been set, as explained
in the HTTP RFC.
2013-11-09 18:26:49 +01:00
Loïc Hoguin
a0205779fe Remove an unnecessary clause in cowboy_req:body/2 2013-11-09 18:08:54 +01:00
Loïc Hoguin
ff4871a9c9 Use try/catch instead of catch
Thanks Richard Carlsson for the remainder.
2013-11-09 17:54:03 +01:00
Loïc Hoguin
1e892e2e3b Merge branch 'dsucher-better-routes-without-start-slash-error' 2013-11-08 22:56:21 +01:00
Danielle Sucher
37e98f019d Clarify error msg for route lacking starting slash 2013-11-08 22:56:09 +01: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
8d546dacbc Optimize query string parsing
*  Parsing code was moved to cowlib: cowboy_qs:parse_qs/1
 *  A function was added to build query strings: cowboy_qs:qs/1
 *  Also added cowboy_qs:urlencode/1 and cowboy_qsurldecode/1
2013-11-08 18:47:05 +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
faf64524c6 Move cookie parsing/building code to cowlib
The code for parsing has also been rewritten to be more efficient
and to be able to handle cookie values with space inside them properly.

Update cowlib to 0.2.0.
2013-10-23 16:35:23 +02:00
Loïc Hoguin
299c93f661 Implement recv timeout for SPDY 2013-09-07 14:01:19 +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
bd0de074c3 More SPDY code readability improvements 2013-09-04 12:47:27 +02:00
Loïc Hoguin
bf70b41282 Fix a badmatch issue when calling which_children on SPDY process 2013-09-04 12:30:45 +02:00
Loïc Hoguin
d83205243a Simplify the SPDY code by adding child management functions 2013-09-04 12:29:30 +02:00
Loïc Hoguin
9b52ccad03 Fix specs for SPDY 2013-09-02 20:14:48 +02:00
Loïc Hoguin
67410731e0 Merge branch 'ipv6-literal' of git://github.com/yamt/cowboy 2013-09-02 20:05:03 +02: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
YAMAMOTO Takashi
201c53cb9f make cowboy_client:request() allow to override Host header
this will be used by tests
2013-09-03 02:09:10 +09:00
YAMAMOTO Takashi
43b3c39a0c add unit test for cowboy_protocol:parse_host/1 2013-09-03 02:09:10 +09:00
YAMAMOTO Takashi
77f7427b41 cowboy_protocol: accept host using ipv6 literal 2013-09-03 02:08:55 +09:00
Loïc Hoguin
0d5a12c3ec Merge branch 'fix-ws-atom-responses' of git://github.com/seriyps/cowboy 2013-08-27 18:21:03 +02:00
Loïc Hoguin
b22f25d902 Merge branch 'websocket-compressed-metadata' of git://github.com/irccloud/cowboy 2013-08-27 18:10:51 +02:00
Loïc Hoguin
bbee34fe16 Crash on failure, don't report errors
When something went wrong in a handler we used to report errors
and then terminate the process normally. This doesn't work so
well with links which won't detect failure.

Now we still catch the error, but throw another one with more
details on why it happened, including the Req object information
and the stacktrace. Ranch will then print an error message with
all this information.

Because we crash directly, this also means that we will not hog
resources unnecessarily for too long when something bad happens.
2013-08-24 20:36:23 +02:00
Loïc Hoguin
bfb6db1eab Simpler code for sending errors following crashes 2013-08-24 20:21:05 +02:00
RJ
83d85e641a add websocket_compress metadata 2013-08-15 10:47:18 +01:00
Sergey Prokhorov
01d30568dd Allow atom responses in websocket handlers #563 2013-08-13 23:29:16 +04:00
pmyarchon
95c915dfaa Slight docs fix in cowboy_req.erl 2013-07-18 12:16:03 +04: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
Ali Sabil
c5c9c398ff Use the proper typespec for the websocket_deflate_frame rsv bits 2013-07-08 09:49:35 +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
6f0b8804bc Fix handling of websocket fragmented deflated frames 2013-07-02 13:46:28 +02:00
Ali Sabil
a3b9438d16 Fix websocket unmasking when compression is enabled
The unmasking logic was based on the length of inflated data instead
of the length of the deflated data. This meant data would get corrupted
when we receive a websocket frame split across multiple TCP packets.
2013-07-02 13:46:28 +02:00
Ali Sabil
373f2e8134 Fix coding style in websocket_deflate_frame/3 2013-07-02 11:02:32 +02:00
Ali Sabil
4edef3c45c Remove usage of the inflate buffer 2013-07-02 10:58:12 +02:00
Loïc Hoguin
116acaead7 Remove unknown keys from .app.src file 2013-06-27 19:25:43 +02:00
Loïc Hoguin
9eaee45c09 Fix compilation < R16B01 2013-06-20 18:44:36 +02:00
Loïc Hoguin
0529f85492 Update to 0.8.6 2013-06-20 16:02:33 +02:00
Loïc Hoguin
11493a40f1 Ignore deprecation warning for crypto:sha/1 for now
We can change this call when we start supporting only R16B+,
which may happen when R17B is released or some time 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
ba1eca6b97 Avoid crashing in cowboy_req on invalid Accept-Encoding header
Certain clients send malformed Accept-Encoding headers, which causes
cowboy_req to crash is compression is enabled.
2013-06-10 15:22:05 +02:00
Loïc Hoguin
a55c20c4ef Merge branch 'dont_overwrite_stacktrace' of git://github.com/urbanserj/cowboy 2013-06-08 21:50:58 +02:00
Loïc Hoguin
830d4c85c8 Merge branch 'read_with_utc' of git://github.com/narma/cowboy 2013-06-07 19:07:38 +02:00
Sergey Urbanovich
1577ec8364 Don't overwrite stacktrace in cowboy_rest:error_terminate/2
This stacktrace is very useful in the `onresponse` hook. For example:

```erlang
internal_error_hook(500, Headers, <<>>, Req) ->
    StackTrace = erlang:get_stacktrace(),
    Headers0 = [{N, V} || {N, V} <- Headers, N =/= <<"content-length">>],
    Body = io_lib:format("~p", [StackTrace]),
    {ok, Req0} = cowboy_req:reply(500, Headers0, Body, Req),
    Req0;
internal_error_hook(Status, Headers, Body, Req) ->
    {ok, Req0} = cowboy_req:reply(Status, Headers, Body, Req),
    Req0.
```
2013-06-07 21:06:27 +04:00
Loïc Hoguin
a8737cb763 Merge branch 'types' of git://github.com/lavrin/cowboy 2013-06-07 18:40:44 +02:00
Loïc Hoguin
be0f7a214c Merge branch 'spdy-zero-length-header-names' of git://github.com/bgentry/cowboy 2013-06-07 18:36:29 +02:00
Sergey Rublev
d6c9bb27ad Use read_file_info/2 with {time, universal} option 2013-06-07 22:21:42 +07:00
Loïc Hoguin
5179b0647b Fix a couple control_frame clauses that were too large 2013-06-05 10:47:04 +02:00
Loïc Hoguin
1fc69977da Add sendfile support to SPDY, enabling cowboy_static use 2013-06-03 19:10:03 +02:00
Radosław Szymczyszyn
e4f407e426 Fix cowboy:start_http/https/spdy typespecs 2013-06-02 00:40:22 +02:00