Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: ngmoco/cowboy
base: master
head fork: RJ/cowboy
compare: x-webkit-deflate-frame
Commits on Feb 02, 2012
Loïc Hoguin Apply a trick to the erlang:hibernate calls to suppress dialyzer warn…

Initially recommended by Magnus Klaar, the trick is to add a catch
instruction before the erlang:hibernate/3 call so that Dialyzer
thinks it will return, followed by the expected return value
('ok' for HTTP, 'closed' for websockets).

This should be good enough until a real solution is found.
David Kelly Added absoluteURI support
If requests go through a proxy, they will have the original uri in the
request, i.e. : GET http://proxy.server.uri/some/query/string  HTTP 1.1 ...

That was problematic -- cowboy_http_protocol:request didn't know what to
to with the result of decode_packet applied to this, which would be something

``` erlang

So, I just ignore the host, grab the path and pass into

``` erlang
cowboy_http_protocol:request({http_request, Method, {abs_path, Path},
	Version}, State)

Seems to do the trick without much effort.
Commits on Feb 08, 2012
Pedram Nimreezi DeadZen Add CA support and make SSL certificate password optional e67d839
Commits on Feb 20, 2012
Loïc Hoguin Add 'Expect' header parsing
At the same time renaming cowboy_http:content_type_params/3 to
cowboy_http:params/2 (with a default Acc of []) as this code isn't
useful only for content types.
Loïc Hoguin REST: Only send 201 when a new resource is created on POST f6cf731
Loïc Hoguin Add an examples/ directory containing a link to cowboy_examples 9baf3e2
Loïc Hoguin Merge branch 'ssl-password-cacert' of 811d11a
Loïc Hoguin Check for upgrades on accept timeout
Otherwise acceptors will not be upgraded properly until after the
next request comes in.

Thanks to DeadZen for pointing it out.
Commits on Feb 21, 2012
Roberto Ostinelli ostinelli polished dialyzer warnings on supervisor init/1 specs f3de086
Commits on Feb 23, 2012
Loïc Hoguin Add cowboy_http:x_www_form_urlencoded/2
This was initially an internal function, it has been made public
due to popular demand as it can sometimes be needed.
Commits on Feb 24, 2012
Loïc Hoguin Add an empty ebin/ folder to fix a rebar/edoc issue
When missing rebar couldn't build docs because it expects the ebin/
folder to exist before it runs edoc. This commit allows users to
build docs without first having to run make.
Loïc Hoguin essen Merge pull request #146 from ostinelli/f3de0869801d3909cc5a5d5dbee819…

Polish dialyzer warnings on supervisor init/1
Commits on Feb 27, 2012
Loïc Hoguin Remove a completed @todo comment ac1424f
Loïc Hoguin Remove the redundant include/ from -include("http.hrl") d9212c2
Loïc Hoguin Add a roadmap 8f0a78f
Commits on Feb 29, 2012
Magnus Klaar Tests and fixes for the generate_etag/2 callback
The return value from the generate_etag/2 callback is expected to be a
binary tagged with either weak or strong. This binary is quoted, and
may be prefixed with W/ before it is set as the value of the ETag header
in the response.

For backwards compatibility with older handlers where the return value
was expected to be a quoted binary a function has been added to parse any
return values that are untagged binaries. All untagged binaries are expected
to be a valid value for the ETag header.
Commits on Mar 02, 2012
Loïc Hoguin Merge branch 'rest-etag-fixes' of c6c2b31
Commits on Mar 08, 2012
Tim Dysinger dysinger If we have a mapping to '*' then use it as the default catch all accept 21cd61c
Commits on Mar 09, 2012
Ali Sabil asabil Make media type parsing more relaxed
Certain user agents send slightly invalid media types, like the
following: "text/html, image/gif, image/jpeg, ; q=.2, */; q=.2"

The user agent with which this behavior was observed presented itself
with the User-Agent string: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X
10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (FlipboardProxy/0.0.5;
Magnus Klaar Fix issue #157 relating to daylight savings time. 3376b72
Loïc Hoguin Merge branch 'cookie-expire-fix' of 5d46ad0
Commits on Mar 12, 2012
Loïc Hoguin Rename inet:ip_port() to inet:port_number()
Thanks go to @superbobry for pointing it out.
Loïc Hoguin Merge branch 'fix/relax-media-type-parsing' of… 133564d
Commits on Mar 13, 2012
Loïc Hoguin Merge branch 'content-type-accepted-asterisk-atom' of https://github.…

Added a comment explaining the '*' always matching.
Loïc Hoguin Do not send chunked Transfer-Encoding replies for HTTP/1.0
Fixes compatibility issue #140 reported by @majek.
Commits on Mar 15, 2012
Loïc Hoguin Add an 'onrequest' hook for HTTP
This new protocol option is a fun.

It expects a single arg, the Req, and should only return a possibly
modified Req. This can be used for many things like URL rewriting,
access logging or listener-wide authentication.

If a reply is sent inside the hook, then Cowboy will consider the
request handled and will move on to the next one.
Loïc Hoguin Don't close requests when the replied body is chunked 7e74582
Commits on Mar 21, 2012
Ali Sabil asabil Simplify the options filtering code in cowboy_ssl_transport 98c5828
Ali Sabil asabil Add support for specifying the ciphers for the SSL transport 9ac784d
Commits on Mar 22, 2012
Dmitry Groshev si14 Fixing badmatch when browser closes connection earlier than file was …
…fully sent
Commits on Mar 23, 2012
Loïc Hoguin Merge branch 'patch-1' of 7b2793b
Ali Sabil asabil Update the edoc for cowboy_ssl_transport:listen/1 0c2cb20
Loïc Hoguin Merge branch 'add-ssl-ciphers-configuration' of… 4fb2a6f
Commits on Apr 01, 2012
Magnus Klaar Convert request to proplist when logging 5a7040e
Loïc Hoguin Merge branch 'log-proplist-req' ba75e8b
Loïc Hoguin Add chunked transfer encoding support and rework the body reading API
Introduces 3 low level functions and updates the existing higher
levels functions. The new primitives are has_body/1, body_length/1
and stream_body/1. In addition to that, a helper function
init_stream/4 has been added.

Streaming a body implies to decode the Transfer-Encoding and
Content-Encoding used for the body. By default, Cowboy will try
to figure out what was used and decode them properly. You can
override this if you want to disable this behavior or simply
support more encodings by calling the init_stream/4 function
before you start streaming the body.
Commits on Apr 05, 2012
Magnus Klaar Add support for fragmented websocket messages 0b15ed9
Commits on Apr 06, 2012
Magnus Klaar Update autobahn suite to use autobahntestsuite 80c67bf
Andrew Thompson Vagabond Add sockname/1 to the TCP and SSL transports 06a2d63
Loïc Hoguin Merge branch 'websocket-fragments' of e8ee647
Loïc Hoguin Merge branch 'adt-add-sockname' of 85ed79e
Commits on Apr 08, 2012
Ali Sabil asabil Make charsets parsing more relaxed
Certain user agents send invalid Accept-Charset headers, like the
following: "ISO-8859-1;utf-8;q=0.7,*;q=0.7"

The user agent with which this behavior was observed presented itself
with the User-Agent string: "Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.9) Gecko/2008052906 Firefox/3.0" Although this doesn't
appear to be correct. The request might have been mangled by a
transparent proxy.
Commits on Apr 12, 2012
Loïc Hoguin Use a separate rebar.config file for running tests 4b27d3e
Loïc Hoguin Cleanup the .gitignore 1219837
Commits on Apr 13, 2012
Loïc Hoguin Add a clean-docs target to the Makefile bc2d53d
Commits on Apr 24, 2012
Bob Ippolito etrepum use erlang:start_timer/3 instead of erlang:send_after/3 for handling …
Commits on Apr 28, 2012
Loïc Hoguin Add .cowboy.plt to the gitignore 845d306
Commits on Apr 29, 2012
Loïc Hoguin Fix and rework the HTTP test suite
Use a proper HTTP client to run all tests. This client is currently
undocumented and should not be used.

Includes a few fixes:

* Fix a bug in the max_keepalive test
* Fix a bug with max_keepalive handling
* Fix a bug in stream_body/1 where data was lost under some conditions

The tests now run quite faster than before.

All the tests now run twice: once for TCP, once for SSL.
Commits on Apr 30, 2012
Loïc Hoguin Merge branch 'cowboy-client' 48a2b17
Magnus Klaar Add file option to cowboy_http_static 8168ae9
Loïc Hoguin Refactor the reply functions 7ed93fc
Commits on May 02, 2012
Loïc Hoguin Add a test for HTTP handlers loop timeouts dab6648
Commits on May 03, 2012
Loïc Hoguin Merge branch 'cancel-timer' of 1524ba4
Commits on May 04, 2012
Loïc Hoguin Add an 'onresponse' hook
This new protocol option is a fun.

It expects 3 args: the Status code used in the reply (this is the
cowboy_http:status() type, it can be an integer or a binary), the
headers that will be sent in the reply, and the Req. It should
only return a possibly modified Req. This can be used for many
things like error logging or custom error pages.

If a reply is sent inside the hook, then Cowboy will discard the
reply initially sent. Extra caution must be used in the handlers
making use of inline chunked replies as they will throw an error.

This fun cannot be used as a filter, you can either observe the
reply sent or discard it to send a different one instead.

The hook will not be called for replies sent from inside the hook.
Loïc Hoguin Merge branch 'response-hook' 0406a63
Loïc Hoguin Add a note about crypto websocket usage in the doc comments 14b45fd
Yurii Rashkovskii yrashk Fixes invalid type specification for cowboy_http_req:multipart_data/1 d495582
Commits on May 05, 2012
Loïc Hoguin Add a test for empty path segments 376d537
Loïc Hoguin Merge branch 'patch-1' of 5ffeb9e
Loïc Hoguin Add a test checking requests with size around the MTU 90bae59
Commits on May 06, 2012
Anthony Ramine nox Add new HTTP status codes from RFC 6585
See for further details.
Commits on May 14, 2012
Loïc Hoguin essen Merge pull request #216 from nox/rfc6585
Add new HTTP status codes from RFC 6585
Tom Burdick bfrog Only ignore slashes in cookie values for the path
* Ensures cookie encoding errors are caught earlier
* Fix separator misspelling
Commits on May 21, 2012
Loïc Hoguin Small updates to the ROADMAP and doc comments 8363e89
Loïc Hoguin Make multipart code use stream_body ca9278b
Loïc Hoguin Fix a bug preventing 'onresponse' from being called on errors cc6c4e3
Loïc Hoguin Merge branch 'fix/relax-conneg-parsing' of… 040c6dc
Loïc Hoguin Merge branch 'serve-static-file' of
Fix alphabetical order since @klaar seems to have issues with it. ;)
Loïc Hoguin Merge branch 'cookie_slash' of a95245d
Loïc Hoguin Remove a dumb warning when running the tests 1a1b01c
Commits on May 23, 2012
Loïc Hoguin Update version to 0.6.0
Also update the CHANGELOG and copyright years.
Commits on Jul 13, 2012
Loïc Hoguin essen Add an Hello World example b8a25b1
Commits on Jul 14, 2012
Loïc Hoguin essen Add a simple Static File Server example 86f9f48
Commits on Jul 21, 2012
Loïc Hoguin essen REST: Fix charset matching 95ed134
Loïc Hoguin essen REST: Normalize content types accepted
Same as content types provided, we accept the <<"application/json">> form.
Commits on Jul 22, 2012
Loïc Hoguin essen Add support for Expect: 100-continue
This makes uploading files with curl a lot faster than without.
Loïc Hoguin essen Add a GET echo example 370b3d9
Loïc Hoguin essen Add a POST echo example 73c0737
Loïc Hoguin essen Add a Chunked Hello World example 6ea32d6
Loïc Hoguin essen Add a REST Hello World example f212caf
Loïc Hoguin essen Look for parsed headers in the cache before trying to parse adc3639
Loïc Hoguin essen Remove an useless todo bab6290
Commits on Jul 23, 2012
Josh Marchán Don't save parsed value in the Host header f3c5881
Loïc Hoguin essen Improve typespecs 76d6ed8
Commits on Jul 31, 2012
Seven Du seven1240 Fix stream_body when used by multipart 2645044
Commits on Aug 08, 2012
Loïc Hoguin essen Update version to 0.6.1 af07e04
Commits on Aug 09, 2012
Loïc Hoguin essen Update AUTHORS file 50e5a61
Commits on Aug 27, 2012
Loïc Hoguin essen Switch to Ranch for connection handling
This is the first of many API incompatible changes.

You have been warned.
Loïc Hoguin essen Have only one -export and -export_type per line
This should make easier spotting additions and removals in commits.
Loïc Hoguin essen Change a websocket error from {error, protocol} to {error, badframe}
For improved consistency.
Loïc Hoguin essen Update behaviours for R15B+
This effectively drops the R14B compatibility.

The cowboy_req:req() type will be introduced in a future commit.
It refers to the #http_req{} record.
Loïc Hoguin essen Rename cowboy_http_protocol to cowboy_protocol 9e2622b
Loïc Hoguin essen Rename cowboy_http_req to cowboy_req d3dcaf1
Loïc Hoguin essen Rename cowboy_http_rest to cowboy_rest 6d84afd
Loïc Hoguin essen Rename cowboy_http_static to cowboy_static f39c001
Loïc Hoguin essen Rename cowboy_http_websocket to cowboy_websocket 0e3adf1
Loïc Hoguin essen Introduce a cowboy_req:req/0 type
Cleanup the typespecs of the cowboy_req module following this.
Commits on Sep 10, 2012
Loïc Hoguin essen Replace cowboy_req:host/1 with cowboy_req:raw_host/1
The latter is much more useful than the former, which ends up
being removed.
Loïc Hoguin essen Replace cowboy_req:path/1 with cowboy_req:raw_path/1
The latter is much more useful than the former, which ends up
being removed.
Commits on Sep 14, 2012
Loïc Hoguin essen Separate multipart from body_state 4040a9f
Loïc Hoguin essen Change type #http_req{} to cowboy_req:req()
This removes cowboy_static's dependency on http.hrl.
Commits on Sep 15, 2012
Loïc Hoguin essen Remove two unneeded Req modifications 9b5cbb5
Loïc Hoguin essen Add a cowboy_req:to_list/1 function
Removes a lot of duplicate code when printing error messages.
Loïc Hoguin essen Put socket and transport into cowboy_websocket's #state{}
As part of the work to make cowboy_req:req() opaque.
Loïc Hoguin essen Avoid a duplicate HTTP reply in cowboy_websocket:upgrade_error/1
Do this by checking whether we received the resp_sent message.
Loïc Hoguin essen Add cowboy_req:url/1 to return the full request URL
Use it in cowboy_websocket for hixie76, replacing http by ws.
Loïc Hoguin essen Remove duplicate code for ensure_response 0aaa717
Loïc Hoguin essen Use skip_body directly between requests
There's no need for more complex logic now that we have
the API for it.
Loïc Hoguin essen Introduce cowboy_req:set_meta/3 to set request metadata 9ef94fb
Loïc Hoguin essen Put the method in cowboy_rest's #state{} 736bcd4
Loïc Hoguin essen Introduce cowboy_req:host_url/1 to remove more duplicate code 527477b
Commits on Sep 16, 2012
Loïc Hoguin essen Add cowboy_req:delete_resp_header/2
Both requested and better for making Req opaque.
Commits on Sep 17, 2012
Loïc Hoguin essen Improve consistency of return types for cowboy_req API
The signature of parse_header, body_qs, multipart_data and
the set_resp_* functions has changed.

See the cowboy_req module edoc for more details.
Loïc Hoguin essen Add a function to lock request responses instead of inlining
Just more cleanup in order to have req() opaque.
Loïc Hoguin essen Remove http.hrl dependency in cowboy_rest
Only cowboy_protocol remaining now.
Loïc Hoguin essen Use cowboy_req:version/1 in cowboy_protocol where applicable
More cleanup towards making cowboy_req:req() opaque.
Loïc Hoguin essen Add a private cowboy_req function to create a Req object
Private means you must not used it. It's meant for internal use.
Loïc Hoguin essen Add the private function set_host/4 used by cowboy_protocol 350d4ae
Loïc Hoguin essen Add the private set_connection/2 function used by cowboy_protocol 905083a
Loïc Hoguin essen Add the private add_header/3 function used by cowboy_protocol fc02b7f
Loïc Hoguin essen Add the private set_buffer/2 function used by cowboy_protocol 5b56dd7
Loïc Hoguin essen Add the private set_bindings/4 function used by cowboy_protocol c1dd5b5
Loïc Hoguin essen Add the private get_resp_state/1 function used by cowboy_protocol e55ec7d
Loïc Hoguin essen Add the private get_buffer/1 function used by cowboy_protocol cf0e905
Loïc Hoguin essen Add the private get_connection/1 function used by cowboy_protocol
This removes cowboy_protocol's dependency on http.hrl!
Loïc Hoguin essen Make cowboy_req:req() opaque
Remove http.hrl in the process.

If you feel furious about this change after reaching this commit,
don't worry! You probably just need a few access or modification
functions to be added in cowboy_req for your needs. Problem is,
I don't know these. I'll be very thankful if you can open a ticket
and tell me all about it so the best solution can be swiftly
implemented to make you happy again.
Loïc Hoguin essen Include the eunit file only if TEST is defined 13b743b
Loïc Hoguin essen Rename cowboy_req:raw_qs/1 to cowboy_req:qs/1 18be3a8
Loïc Hoguin essen Replace many proplists:get_value/{2,3} calls by BIFs
Originally suggested by Roberto Ostinelli.
Loïc Hoguin essen Add types for onrequest and onresponse funs c2be7c1
Loïc Hoguin essen Update CHANGELOG f6791b0
Commits on Sep 21, 2012
Loïc Hoguin essen Don't use decode_packet/3 for parsing the request-line
First step in making all methods and header names binaries to
get rid of many inconsistencies caused by decode_packet/3.

Methods are all binary now. Note that since they are case
sensitive, the usual methods become <<"GET">>, <<"POST">> and so on.
Loïc Hoguin essen Don't use decode_packet/3 for parsing the headers
Header names are now binaries. Since header names are case insensitive
they are all converted to lowercase. For example: <<"content-length">>.

The max_line_length option was removed. Three new options have been
added instead:

 *  max_request_line_length (defaults to 4096)
 *  max_header_name_length (defaults to 64)
 *  max_header_value_length (defaults to 4096)
Loïc Hoguin essen Make multipart part headers binary lowercase
Here we do not remove decode_packet yet, we just lowercase the
header name and transform it into a binary if needed, to fix
the consistency issue.
Loïc Hoguin essen Update CHANGELOG 981ea35
Commits on Sep 30, 2012
Richard Jones RJ add websockets example a74fbd7
Richard Jones RJ implement x-webkit-deflate-frame for websockets 675a648