Permalink
Browse files

Merge remote branch 'upstream/master'

  • Loading branch information...
2 parents e42bad3 + 09914c4 commit 637600f40c77593bda976f08b76c4ddbdbec6795 @nivertech committed Oct 13, 2012
View
@@ -6,6 +6,8 @@ next
* This release drops R14 compatibility
+* Add CONTRIBUTING.md file
+
* Use Ranch for connection handling
To start listeners you can now use cowboy:start_http/4 for HTTP,
@@ -64,10 +66,16 @@ next
* max_header_name_length, defaults to 64 bytes
* max_header_value_length, defaults to 4096 bytes
+* Add max_headers option, limiting the number of headers; defaults to 100
+
* Use -callback in behaviours
* Add cowboy_protocol:onrequest_fun/0 and :onresponse_fun/0 types
+* Add the body data to onresponse_fun/0 callback
+
+* Remove the urldecode cowboy_protocol option
+
* Isolate multipart from body reading to fix an issue
* Change a websocket error from {error, protocol} to {error, badframe}
View
@@ -0,0 +1,137 @@
+Contributing
+============
+
+Introduction
+------------
+
+This document describes the usages and rules to follow when contributing
+to this project.
+
+It uses the uppercase keywords SHOULD for optional but highly recommended
+conditions and MUST for required conditions.
+
+`git` is a distributed source code versioning system. This document refers
+to three different repositories hosting the source code of the project.
+`Your local copy` refers to the copy of the repository that you have on
+your computer. The remote repository `origin` refers to your fork of the
+project's repository that you can find in your GitHub account. The remote
+repository `upstream` refers to the official repository for this project.
+
+Following this document will ensure prompt merging of your work in the
+`master` branch of the project.
+
+Planning
+--------
+
+Upon identifying a bug, you SHOULD submit a ticket, regardless of your
+plans for fixing it. If you plan to fix the bug, you SHOULD discuss your
+plans to avoid having your work rejected.
+
+Before implementing a new feature, you SHOULD submit a ticket for discussion
+on your plans. The feature might have been rejected already, or the
+implementation might already be decided.
+
+Cloning
+-------
+
+You MUST fork the project's repository to your GitHub account by clicking
+on the `Fork` button.
+
+Then, from your fork's page, copy the `Git Read-Only` URL to your clipboard.
+You MUST perform the following commands in the folder you choose, replacing
+`$URL` by the URL you just copied, `$UPSTREAM_URL` by the `Git Read-Only`
+project of the official repository, and `$PROJECT` by the name of this project.
+
+``` bash
+$ git clone "$URL"
+$ cd $PROJECT
+$ git remote add upstream $UPSTREAM_URL
+```
+
+Branching
+---------
+
+Before starting working on the code, you MUST update to `upstream`. The
+project is always evolving, and as such you SHOULD always strive to keep
+up to date when submitting patches to make sure they can be merged without
+conflicts.
+
+To update the current branch to `upstream`, you can use the following commands.
+
+``` bash
+$ git fetch upstream
+$ git rebase upstream/master
+```
+
+It may ask you to stash your changes, in which case you stash with:
+
+``` bash
+$ git stash
+```
+
+And put your changes back in with:
+
+``` bash
+$ git stash pop
+```
+
+You SHOULD use these commands both before working on your patch and before
+submitting the pull request. If conflicts arise it is your responsability
+to deal with them.
+
+You MUST create a new branch for your work. First, ensure you are on `master`.
+You MUST update `master` to `upstream` before doing anything. Then create a
+new branch `$BRANCH` and switch to it.
+
+``` bash
+$ git checkout -b $BRANCH
+```
+
+You MUST use a an insightful branch name.
+
+If you later need to switch back to an existing branch `$BRANCH`, you can use:
+
+``` bash
+$ git checkout $BRANCH
+```
+
+Source editing
+--------------
+
+The following rules MUST be followed:
+ * Indentation uses horizontal tabs, 1 tab equals the length of 4 space chars
+ * Do NOT align code; only indentation is allowed
+
+The following rules SHOULD be followed:
+ * Write small functions whenever possible
+ * Avoid having too many clauses containing clauses containing clauses
+
+Committing
+----------
+
+You MUST ensure that all commits pass all tests and do not have extra
+Dialyzer warnings.
+
+You MUST put all the related work in a single commit. Fixing a bug is one
+commit, adding a feature is one commit, adding two features is two commits.
+
+You MUST write a proper commit title and message. The commit title MUST be
+at most 72 characters; it is the first line of the commit text. The second
+line of the commit text MUST be left blank. The third line and beyond is the
+commit message. You SHOULD write a commit message. If you do, you MUST make
+all lines smaller than 80 characters. You SHOULD explain what the commit
+does, what references you used and any other information that helps
+understanding your work.
+
+Submitting the pull request
+---------------------------
+
+You MUST push your branch `$BRANCH` to GitHub, using the following command:
+
+``` bash
+$ git push origin $BRANCH
+```
+
+You MUST then submit the pull request by using the GitHub interface.
+You SHOULD provide an explanatory message and refer to any previous ticket
+related to this patch.
View
@@ -39,7 +39,8 @@ Cowboy does nothing by default.
Cowboy uses Ranch for handling connections, and provides convenience
functions to start and stop Ranch listeners. The Ranch application
-must always be started before Cowboy.
+must always be started before Cowboy. The crypto application must
+also be started.
The `cowboy:start_http/4` function will handle HTTP connections
using the TCP transport. Similarly, `cowboy:start_https/4` will
@@ -57,6 +58,7 @@ HTTP listener. It redirects all requests to the `my_handler`
module.
``` erlang
+application:start(crypto),
application:start(ranch),
application:start(cowboy),
Dispatch = [
View
@@ -56,11 +56,6 @@ are not ordered.
Cowboy. The server code should be reviewed and tested
to ensure compatibility with remaining HTTP/1.0 products.
-* HTTP 100 Continue support.
-
- Tools like curl expect a 100 Continue before sending a
- request body by default.
-
* Complete the work on Websockets.
Now that the Autobahn test suite is available (make inttests),
@@ -8,6 +8,7 @@
%% API.
start() ->
+ ok = application:start(crypto),
ok = application:start(ranch),
ok = application:start(cowboy),
ok = application:start(chunked_hello_world).
@@ -8,6 +8,7 @@
%% API.
start() ->
+ ok = application:start(crypto),
ok = application:start(ranch),
ok = application:start(cowboy),
ok = application:start(echo_get).
@@ -8,6 +8,7 @@
%% API.
start() ->
+ ok = application:start(crypto),
ok = application:start(ranch),
ok = application:start(cowboy),
ok = application:start(echo_post).
@@ -8,6 +8,7 @@
%% API.
start() ->
+ ok = application:start(crypto),
ok = application:start(ranch),
ok = application:start(cowboy),
ok = application:start(hello_world).
@@ -28,7 +28,7 @@ server: Cowboy
date: Fri, 28 Sep 2012 04:15:52 GMT
content-length: 136
Content-Type: text/html
-Variances: Accept
+Vary: Accept
<html>
<head>
@@ -51,7 +51,7 @@ server: Cowboy
date: Fri, 28 Sep 2012 04:16:46 GMT
content-length: 24
Content-Type: application/json
-Variances: Accept
+Vary: Accept
{"rest": "Hello World!"}
```
@@ -66,7 +66,7 @@ server: Cowboy
date: Fri, 28 Sep 2012 04:18:35 GMT
content-length: 25
Content-Type: text/plain
-Variances: Accept
+Vary: Accept
REST Hello World as text!
```
@@ -8,6 +8,7 @@
%% API.
start() ->
+ ok = application:start(crypto),
ok = application:start(ranch),
ok = application:start(cowboy),
ok = application:start(rest_hello_world).
@@ -1,4 +1,6 @@
{deps, [
{cowboy, ".*",
- {git, "git://github.com/extend/cowboy.git", "master"}}
+ {git, "git://github.com/extend/cowboy.git", "master"}},
+ {mimetypes, ".*",
+ {git, "git://github.com/spawngrid/mimetypes.git", "master"}}
]}.
@@ -8,6 +8,7 @@
%% API.
start() ->
+ ok = application:start(crypto),
ok = application:start(ranch),
ok = application:start(cowboy),
ok = application:start(static).
@@ -14,7 +14,8 @@ start(_Type, _Args) ->
Dispatch = [
{'_', [
{['...'], cowboy_static, [
- {directory, {priv_dir, static, []}}
+ {directory, {priv_dir, static, []}},
+ {mimetypes, {fun mimetypes:path_to_mimes/2, default}}
]}
]}
],
View
@@ -20,7 +20,8 @@
{applications, [
kernel,
stdlib,
- ranch
+ ranch,
+ crypto
]},
{mod, {cowboy_app, []}},
{env, []}
@@ -34,7 +34,7 @@
%% any dispatching is done. Host info, path info and bindings are thus
%% not available at this point.</dd>
%% <dt>onresponse</dt><dd>Optional fun that allows replacing a response
-%% sent by the application based on its status code or headers.</dd>
+%% sent by the application.</dd>
%% <dt>timeout</dt><dd>Time in milliseconds before an idle
%% connection is closed. Defaults to 5000 milliseconds.</dd>
%% </dl>
@@ -56,7 +56,7 @@
-type onrequest_fun() :: fun((Req) -> Req).
-type onresponse_fun() ::
- fun((cowboy_http:status(), cowboy_http:headers(), Req) -> Req).
+ fun((cowboy_http:status(), cowboy_http:headers(), iodata(), Req) -> Req).
-export_type([onrequest_fun/0]).
-export_type([onresponse_fun/0]).
View
@@ -399,7 +399,6 @@ parse_header(Name, Req=#http_req{p_headers=PHeaders}) ->
%% @doc Default values for semantic header parsing.
-spec parse_header_default(binary()) -> any().
-parse_header_default(<<"connection">>) -> [];
parse_header_default(<<"transfer-encoding">>) -> [<<"identity">>];
parse_header_default(_Name) -> undefined.
@@ -430,33 +429,21 @@ parse_header(Name, Req, Default) when Name =:= <<"accept-language">> ->
cowboy_http:nonempty_list(Value, fun cowboy_http:language_range/2)
end);
parse_header(Name, Req, Default) when Name =:= <<"content-length">> ->
- parse_header(Name, Req, Default,
- fun (Value) ->
- cowboy_http:digits(Value)
- end);
+ parse_header(Name, Req, Default, fun cowboy_http:digits/1);
parse_header(Name, Req, Default) when Name =:= <<"content-type">> ->
- parse_header(Name, Req, Default,
- fun (Value) ->
- cowboy_http:content_type(Value)
- end);
+ parse_header(Name, Req, Default, fun cowboy_http:content_type/1);
parse_header(Name, Req, Default) when Name =:= <<"expect">> ->
parse_header(Name, Req, Default,
fun (Value) ->
cowboy_http:nonempty_list(Value, fun cowboy_http:expectation/2)
end);
parse_header(Name, Req, Default)
when Name =:= <<"if-match">>; Name =:= <<"if-none-match">> ->
- parse_header(Name, Req, Default,
- fun (Value) ->
- cowboy_http:entity_tag_match(Value)
- end);
+ parse_header(Name, Req, Default, fun cowboy_http:entity_tag_match/1);
parse_header(Name, Req, Default)
when Name =:= <<"if-modified-since">>;
Name =:= <<"if-unmodified-since">> ->
- parse_header(Name, Req, Default,
- fun (Value) ->
- cowboy_http:http_date(Value)
- end);
+ parse_header(Name, Req, Default, fun cowboy_http:http_date/1);
%% @todo Extension parameters.
parse_header(Name, Req, Default) when Name =:= <<"transfer-encoding">> ->
parse_header(Name, Req, Default,
@@ -1108,7 +1095,7 @@ response(Status, Headers, RespHeaders, DefaultHeaders, Body, Req=#http_req{
FullHeaders = response_merge_headers(Headers, RespHeaders, DefaultHeaders),
Req2 = case OnResponse of
undefined -> Req;
- OnResponse -> OnResponse(Status, FullHeaders,
+ OnResponse -> OnResponse(Status, FullHeaders, Body,
%% Don't call 'onresponse' from the hook itself.
Req#http_req{resp_headers=[], resp_body= <<>>,
onresponse=undefined})
View
@@ -470,7 +470,7 @@ variances(Req, State=#state{content_types_p=CTP,
resource_exists(Req3, State2);
[[<<", ">>, H]|Variances5] ->
Req4 = cowboy_req:set_resp_header(
- <<"Variances">>, [H|Variances5], Req3),
+ <<"Vary">>, [H|Variances5], Req3),
resource_exists(Req4, State2)
end.
Oops, something went wrong.

0 comments on commit 637600f

Please sign in to comment.