aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_protocol.erl
AgeCommit message (Collapse)Author
2013-01-07Add optional automatic response body compressionLoïc Hoguin
This behavior can be enabled with the `compress` protocol option. See the `compress_response` example for more details. All tests are now ran with and without compression for both HTTP and HTTPS.
2013-01-06Add protection against slowloris vulnerabilityLoïc Hoguin
This changes the behavior of the `timeout` protocol option to mean "Time in which the full request line and headers must be received". The default of 5s should be fine for all normal uses. This change has no noticeable impact on performance and is thus enabled by default for everyone. It can be disabled by setting `timeout` to `infinity` although that is definitely not encouraged. Inspired by the contribution from @naryl on github.
2013-01-03Add middleware supportLoïc Hoguin
Middlewares allow customizing the request processing. All existing Cowboy project are incompatible with this commit. You need to change `{dispatch, Dispatch}` in the protocol options to `{env, [{dispatch, Dispatch}]}` to fix your code.
2012-12-22use the original request when available for error_terminateTom Burdick
this change makes sure that once a request has been created the error_terminate/3 function uses the original request instead of making a new empty one with undefined values making the request attributes easier to look at in many error cases Conflicts: src/cowboy_protocol.erl
2012-12-22Make sure an incorrect port returns a 400 errorLoïc Hoguin
2012-12-13Make the arguments to error_logger more consistentAndrew Thompson
The purpose of this patch is to make the arguments cowboy passes to error_logger more consistent. With this patch there's only 3 variations on the error_logger argument list; a 5 element list, an 8 element list and a 10 element list. In all cases, the first 3 arguments are the Module, Function and Arity of the function being called and the second-to-last argument is always the Request. Additionally, for lists longer than 5 elements, the last argument is always the stack-trace. The added consistency of the argument ordering makes it much easier to write code in lager's error_logger handler to catch these messages and write a pretty one-liner (while writing the full message to the crash.log).
2012-12-03Allow passing the Req and an updated Opts when upgrading protocolsLoïc Hoguin
2012-11-28Clarify error reports indicating they come from CowboyLoïc Hoguin
2012-11-27Fixed onrequest path-related issueserge
2012-10-27Return "400 Bad Request" instead of crashing process on incorrect queries ↵Ivan Blinkov
like /%qq
2012-10-04The onresponse hook now receives 4 arguments, including the bodyLoïc Hoguin
We do not always provide the body however. It is not available when using chunked replies, or when using set_resp_body_fun.
2012-09-29Add max_headers optionLoïc Hoguin
It is only enforced when Cowboy needs to wait for more data. Also fix a few types and a few status codes.
2012-09-29Add missing options in the cowboy_protocol documentationLoïc Hoguin
2012-09-29Remove the urldecode cowboy_protocol optionLoïc Hoguin
This allows inconsistent behavior and is not used enough to be supported.
2012-09-29Add cowboy_req:get/2 and :set/2 private functionsLoïc Hoguin
They should not be used unless you have a very special need, which generally involves interacting with the internals of Cowboy.
2012-09-26Optimize cowboy_protocolLoïc Hoguin
* #state{} changes are avoided where possible * #state{} is now smaller and use less memory * the Req object is created only after the whole request is parsed * parsing makes use of a single binary match context * external calls are avoided in the critical path * URL fragment is now extracted properly (retrieval API next commit) * argument orders to local functions modified to avoid extra operations * dispatching waits as long as possible before tokenizing host/path * handler opts are no longer shown in the error messages except in init The code may not look as beautiful as it was before. But it really is, for parsing code. The parsing section of the file may be skipped if your eyes start to burn.
2012-09-23Extract the buffer out of the #state{} in cowboy_protocolLoïc Hoguin
This reduces the number of operations done each time the buffer changes.
2012-09-23Improve state reset between requestsLoïc Hoguin
2012-09-23Use binary:match/2 instead of binary:split/2Loïc Hoguin
The former is a BIF while the latter is not.
2012-09-21Don't use decode_packet/3 for parsing the headersLoïc Hoguin
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)
2012-09-21Don't use decode_packet/3 for parsing the request-lineLoïc Hoguin
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.
2012-09-17Add types for onrequest and onresponse funsLoïc Hoguin
2012-09-17Replace many proplists:get_value/{2,3} calls by BIFsLoïc Hoguin
Originally suggested by Roberto Ostinelli.
2012-09-17Include the eunit file only if TEST is definedLoïc Hoguin
2012-09-17Add the private get_connection/1 function used by cowboy_protocolLoïc Hoguin
This removes cowboy_protocol's dependency on http.hrl!
2012-09-17Add the private get_buffer/1 function used by cowboy_protocolLoïc Hoguin
2012-09-17Add the private get_resp_state/1 function used by cowboy_protocolLoïc Hoguin
2012-09-17Add the private set_bindings/4 function used by cowboy_protocolLoïc Hoguin
2012-09-17Add the private set_buffer/2 function used by cowboy_protocolLoïc Hoguin
2012-09-17Add the private add_header/3 function used by cowboy_protocolLoïc Hoguin
2012-09-17Add the private set_connection/2 function used by cowboy_protocolLoïc Hoguin
2012-09-17Add the private function set_host/4 used by cowboy_protocolLoïc Hoguin
2012-09-17Add a private cowboy_req function to create a Req objectLoïc Hoguin
Private means you must not used it. It's meant for internal use.
2012-09-17Use cowboy_req:version/1 in cowboy_protocol where applicableLoïc Hoguin
More cleanup towards making cowboy_req:req() opaque.
2012-09-17Add a function to lock request responses instead of inliningLoïc Hoguin
Just more cleanup in order to have req() opaque.
2012-09-17Improve consistency of return types for cowboy_req APILoïc Hoguin
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.
2012-09-15Use skip_body directly between requestsLoïc Hoguin
There's no need for more complex logic now that we have the API for it.
2012-09-15Remove duplicate code for ensure_responseLoïc Hoguin
2012-09-15Add a cowboy_req:to_list/1 functionLoïc Hoguin
Removes a lot of duplicate code when printing error messages.
2012-09-15Change type #http_req{} to cowboy_req:req()Loïc Hoguin
This removes cowboy_static's dependency on http.hrl.
2012-09-15Separate multipart from body_stateLoïc Hoguin
2012-09-10Replace cowboy_req:path/1 with cowboy_req:raw_path/1Loïc Hoguin
The latter is much more useful than the former, which ends up being removed.
2012-09-10Replace cowboy_req:host/1 with cowboy_req:raw_host/1Loïc Hoguin
The latter is much more useful than the former, which ends up being removed.
2012-08-27Rename cowboy_http_websocket to cowboy_websocketLoïc Hoguin
2012-08-27Rename cowboy_http_req to cowboy_reqLoïc Hoguin
2012-08-27Rename cowboy_http_protocol to cowboy_protocolLoïc Hoguin
2012-08-27Switch to Ranch for connection handlingLoïc Hoguin
This is the first of many API incompatible changes. You have been warned.
2012-05-23Update version to 0.6.00.6.0Loïc Hoguin
Also update the CHANGELOG and copyright years.
2011-12-15Add cowboy:accept_ack/1 for a cleaner handling of the shoot messageLoïc Hoguin
2011-10-01Merge branch 'master' of https://github.com/hakvroot/cowboyLoïc Hoguin