Age | Commit message (Collapse) | Author |
|
|
|
This stacktrace is very useful in the `onresponse` hook. For example:
```erlang
internal_error_hook(500, Headers, <<>>, Req) ->
StackTrace = erlang:get_stacktrace(),
Headers0 = [{N, V} || {N, V} <- Headers, N =/= <<"content-length">>],
Body = io_lib:format("~p", [StackTrace]),
{ok, Req0} = cowboy_req:reply(500, Headers0, Body, Req),
Req0;
internal_error_hook(Status, Headers, Body, Req) ->
{ok, Req0} = cowboy_req:reply(Status, Headers, Body, Req),
Req0.
```
|
|
|
|
It was added all the time when * was missing, the RFC specifies it
should only be added if it wasn't already present, though.
|
|
It incorrectly returned a tuple containing the charset and an
associated quality which wasn't being used.
|
|
|
|
|
|
|
|
Adds a new type of streaming response fun. It can be set in a similar
way to a streaming body fun with known length:
Req2 = cowboy_req:set_resp_body_fun(chunked, StreamFun, Req)
The fun, StreamFun, should accept a fun as its single argument. This
fun, ChunkFun, is used to send chunks of iodata:
ok = ChunkFun(IoData)
ChunkFun should not be called with an empty binary or iolist as this
will cause HTTP 1.1 clients to believe the stream is over. The final (0
length) chunk will be sent automatically - even if it has already been
sent - assuming no exception is raised.
Also note that the connection will close after the last chunk for HTTP
1.0 clients.
|
|
|
|
|
|
|
|
The resource accept callback can trigger the following responses:
* returns true, new resource, location header set: 201
* returns true, otherwise: 200, 204 or 300 (depends on body)
* returns false: 422
* returns URL, new resource: 201
* returns URL, otherwise: 303
|
|
|
|
It defaults to setting the Allow header to "HEAD, GET, OPTIONS".
|
|
|
|
For the simple reason that the REST code does nothing about
them.
|
|
Instead it will always go through content_types_accepted and it is
up to the resource code to do any creation and to return the created
path if the method is POST and the client should be redirected to the
created resource's location.
This removes the meta value 'put_path' as it is not needed anymore.
This fixes an issue with PATCH where content types were not normalized.
|
|
For get_type_provided:
'*' will be match any parameters of media-range in "accept" header.
If '*' matched, then '*' is replaced by the matching parameters.
If Accept header is missing and '*' using, then in media_type in parameters
will be '*' and reply content-type will be without any parameters.
For content_types_accepted:
'*' will be match any parameters in "content-type" header.
|
|
|
|
Also improves error reporting.
|
|
Fix #414
|
|
Conflicts:
src/cowboy_rest.erl
|
|
|
|
|
|
|
|
|
|
This allows streaming a body without knowing the length in advance.
Also allows {stream, StreamFun} response body in the REST code.
|
|
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.
|
|
Using a 4xx error would be more appropriate for this since the server is parsing the content from the client and needs to let the client know the data is malformed (not the actual HTTP request but i.e. JSON semantics). The definition for 422 is described in [RFC 4918](https://tools.ietf.org/html/rfc4918#section-11.2)
|
|
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).
|
|
|
|
Add the function cowboy_clock:rfc1123/1 that formats the given
date to the RFC1123 format.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Correct spelling in rest callback name
|
|
|
|
|
|
|
|
|
|
|
|
They should not be used unless you have a very special need,
which generally involves interacting with the internals of Cowboy.
|
|
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.
|
|
Only cowboy_protocol remaining now.
|