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

1091 commits

Author SHA1 Message Date
Loïc Hoguin
dff1b5715c Use cow_http_hd:parse_content_length/1 where applicable 2014-03-24 14:24:52 +01:00
Loïc Hoguin
2629f70ef3 Use cow_http_hd:parse_connection/1 where applicable 2014-03-24 14:24:46 +01:00
Loïc Hoguin
67e5f597ec Remove cowboy_http:urldecode/1 and urlencode/1
Use cow_qs:urldecode/1 and cow_qs:urlencode/1 instead
2014-03-10 10:27:07 +01:00
Loïc Hoguin
8993249e42 Fix typespecs of cowboy_websocket:handler_terminate
Pointed out during the ConcuError tutorial by Kostis. Thanks! :-)
2014-03-08 19:51:39 +01:00
Loïc Hoguin
64f07fe9a3 Keep the whitespace from multiline headers
Before, we could have

Header: the value
 is multiline

Become "the valueis multiline".

Now it will properly be "the value is multiline".
2014-02-27 13:13:35 +01:00
Sina Samavati
b72c420d58 Fix stop_listener/1 spec 2014-02-16 00:16:58 +03:30
Ali Sabil
d145cbb745 Allow empty passwords when parsing Basic authorization header 2014-02-09 18:37:00 +01:00
Loïc Hoguin
903594bb87 Update copyright years 2014-02-06 19:57:23 +01:00
Loïc Hoguin
e85c7a5ee2 Use the INLINE_LOWERCASE macro in the request parsing code
Since I made it for similar code in cowlib, let's use it here too.
2014-02-06 19:50:25 +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
Drew
190938a75e Allows language_range/2 to parse RFC5646 language codes. 2014-01-24 02:44:19 -05:00
Loïc Hoguin
7a274661b2 Fix typespecs for cowboy_req:binding/{2,3} and :bindings/1 2013-12-28 20:10:06 +01:00
Loïc Hoguin
9f33a20d94 Merge branch 'fix/keepalive_loop_stream_recv' of git://github.com/fishcakez/cowboy 2013-12-02 16:14:37 +01:00
Matthias Endler
b2511f15a0 Fix tohexu/1 and tohexl/1
tohexu(16) or tohexl(16) will now crash, instead of evaluating to $G or $g.
2013-11-26 10:19:57 +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
Loïc Hoguin
db52494371 Update Cowboy to 0.9.0 2013-11-14 16:50:35 +01:00
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