Age | Commit message (Collapse) | Author |
|
The options were added to allow developers to fix timeout
issues when reading large bodies. It is also a cleaner and
easier to extend interface.
This commit deprecates the functions init_stream, stream_body
and skip_body which are no longer needed. They will be removed
in 1.0.
The body function can now take an additional argument that is a
list of options. The body_qs, part and part_body functions can
too and simply pass this argument down to the body call.
There are options for disabling the automatic continue reply,
setting a maximum length to be returned (soft limit), setting
the read length and read timeout, and setting the transfer and
content decode functions.
The return value of the body and body_qs have changed slightly.
The body function now works similarly to the part_body function,
in that it returns either an ok or a more tuple depending on
whether there is additional data to be read. The body_qs function
can return a badlength tuple if the body is too big. The default
size has been increased from 16KB to 64KB.
The default read length and timeout have been tweaked and vary
depending on the function called.
The body function will now adequately process chunked bodies,
which means that the body_qs function will too. But this means
that the behavior has changed slightly and your code should be
tested properly when updating your code.
The body and body_qs still accept a length as first argument
for compatibility purpose with older code. Note that this form
is deprecated and will be removed in 1.0. The part and part_body
function, being new and never having been in a release yet, have
this form completely removed in this commit.
Again, while most code should work as-is, you should make sure
that it actually does before pushing this to production.
|
|
|
|
Tiny optimization.
|
|
Before, we could have
Header: the value
is multiline
Become "the valueis multiline".
Now it will properly be "the value is multiline".
|
|
|
|
Since I made it for similar code in cowlib, let's use it here too.
|
|
Thanks Richard Carlsson for the remainder.
|
|
Start moving a few functions from Cowboy into cowlib.
|
|
|
|
|
|
|
|
The SPDY connection processes are also supervisors.
Missing:
* sendfile support
* request body reading support
|
|
|
|
Should improve the detection of wrong protocol options.
|
|
|
|
|
|
|
|
|
|
Now instead of {1, 1} we have 'HTTP/1.1', and instead of {1, 0}
we have 'HTTP/1.0'. This is more efficient, easier to read in
crash logs, and clearer in the code.
|
|
Clients do not send it. We skip the value if we receive it now,
as it shouldn't happen, and won't for all the mainstream clients.
|
|
|
|
It's been found slower than a custom equivalent to what we were
using it for. As this is the critical path we prefer the custom
solution.
|
|
|
|
We now obtain the peer address before creating the Req object.
If an error occurs, then something went wrong, we close the connection
nicely directly.
|
|
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
|
|
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).
|
|
|
|
|
|
|
|
like /%qq
|
|
We do not always provide the body however. It is not available
when using chunked replies, or when using set_resp_body_fun.
|
|
It is only enforced when Cowboy needs to wait for more data.
Also fix a few types and a few status codes.
|
|
|
|
This allows inconsistent behavior and is not used enough to be supported.
|
|
They should not be used unless you have a very special need,
which generally involves interacting with the internals of Cowboy.
|
|
* #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.
|
|
This reduces the number of operations done each time the buffer changes.
|
|
|
|
The former is a BIF while the latter is not.
|
|
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)
|
|
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.
|
|
|
|
Originally suggested by Roberto Ostinelli.
|
|
|