Age | Commit message (Collapse) | Author |
|
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.
|
|
Thanks go to @superbobry for pointing it out.
|
|
|
|
|
|
|
|
At the same time rename http_headers/0 to cowboy_http:headers/0.
|
|
|
|
|
|
Exported types are much better than include files.
|
|
Conflicts:
src/cowboy_http_req.erl
test/http_SUITE.erl
|
|
|
|
We try to send a 500 error only if we didn't send the response
headers yet. If they were, then we have no way to be sure the
response was fully sent, nor should we assume anything about
how this will be handled client-side, so we do nothing more
and in both cases close the connection.
|
|
|
|
* cowboy_http_protocol now defines 'websocket_version' as metadata.
* cowboy_http_rest now defines 'media_type', 'language', 'charset' as metadata.
|
|
resp_body is set by cowboy_http_req:set_resp_body/2 which accepts
the input type iodata(). Update the resp_body field to use the same
type. Also update the cowboy_http_req:has_resp_body/2 function to
use the iolist_size/1 which works with both binary() and iolist()
values instead of the byte_size/1 function which only works with
binary() values.
|
|
This change makes the dependency on quoted optional
by adding a minimal urldecode function to cowboy.
A protocol option for setting the urldecoding function
has been added to the cowboy_http_protocol module.
The default value for this option is set to be
equivalent to the default settings for quoted.
{fun cowboy_http:urldecode/2, crash}
A note has been added in the README to document
how to use quoted instead of this function.
A field to store this option value has been added
to the state record in the cowboy_http_protocol
module and the http_req record in include/http.hrl
Functions that previously used quoted:from_url/1
has been updated to require an equivalent function
in addition to the previously required arguments.
This change removes a C compiler from the build
requirements of cowboy. It also removes the requirement
to cross compile the code if the target arch/OS
is different from the arch/OS used to build it.
|
|
|
|
These functions allow to set response headers and body in advance,
before calling any of the reply functions.
Also add has_resp_header/2 and has_resp_body/1 to check if the given
response headers have already been set.
|
|
You can now return {shutdown, Req, State} from Handler:init/3
to skip the handle/2 step.
Also allow init/3 function to send responses.
|
|
Replaces the 'Connection' interpretation in cowboy_http_protocol
from raw value to the parsed value, looking for a single token
matching close/keep-alive instead of the whole raw value (which
could contain more than one token, for example with Firefox 6+
using websocket).
Introduce the functions cowboy_http_req:parse_header/2 and /3
to semantically parse the header values and return a proper
Erlang term.
|
|
|
|
|
|
Following discussions on #erlounge.
Also fixes compilation in R14B03 and fixes a few underspecs
dialyzer warnings.
|
|
The dispatcher now accepts '...' as the leading segment of Host and the
trailing segment of Path, this special atom matches any remaining path tail.
When given "cowboy.bugs.dev-extend.eu", host rule ['...', <<"dev-extend">>,
<<"eu">>] matches and fills host_info with [<<"cowboy">>, <<"bugs">>].
When given "/a/b/c/d", path rule [<<"a">>, <<"b">>, '...'] matches and fills
path_info with [<<"c">>, <<"d">>].
|
|
Send the status line and headers using
cowboy_http_req:chunked_reply/3, and
individual chunks with cowboy_http_req:chunk/2.
|
|
The server now does a single recv (or more, but only if needed)
which is then sent to erlang:decode_packet/3 multiple times. Since
most requests are smaller than the default MTU on many platforms,
we benefit from this greatly.
In the case of requests with a body, the server usually read at
least part of the body on the first recv. This is bufferized
properly and used when later retrieving the body.
In the case of pipelined requests, we can end up reading many
requests in a single recv, which are then handled properly using
only the buffer containing the received data.
|
|
Returns the port given in the Host header if present,
otherwise the default port of 443 for HTTPS and 80 for HTTP
is returned.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Of course since requests are a record the response state can be explicitly
overriden, but standard use prevents errors by making sure only one reply
is sent.
|
|
|
|
|
|
|
|
|