0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 20:50:24 +00:00
Commit graph

99 commits

Author SHA1 Message Date
Loïc Hoguin
36a6823e50 Do not send chunked Transfer-Encoding replies for HTTP/1.0
Fixes compatibility issue #140 reported by @majek.
2012-03-13 03:00:05 +01:00
Loïc Hoguin
3885912d9b Rename inet:ip_port() to inet:port_number()
Thanks go to @superbobry for pointing it out.
2012-03-12 21:57:07 +01:00
Loïc Hoguin
d9212c21dd Remove the redundant include/ from -include("http.hrl") 2012-02-27 08:07:03 +01:00
Loïc Hoguin
a7264a1af3 Add cowboy_http:x_www_form_urlencoded/2
This was initially an internal function, it has been made public
due to popular demand as it can sometimes be needed.
2012-02-23 20:56:11 +01:00
Loïc Hoguin
f51493ee37 Add 'Expect' header parsing
At the same time renaming cowboy_http:content_type_params/3 to
cowboy_http:params/2 (with a default Acc of []) as this code isn't
useful only for content types.
2012-02-20 08:25:05 +01:00
Loïc Hoguin
16d3cb76c7 Rename the type http_status/0 to cowboy_http:status/0 2012-01-23 09:43:26 +01:00
Loïc Hoguin
a297d5e42b Rename the type http_header/0 to cowboy_http:header/0
At the same time rename http_headers/0 to cowboy_http:headers/0.
2012-01-23 09:36:59 +01:00
Loïc Hoguin
8622dff906 Rename the type http_version/0 to cowboy_http:version/0 2012-01-23 09:28:29 +01:00
Loïc Hoguin
9f40167487 Rename the type http_method/0 to cowboy_http:method/0
Exported types are much better than include files.
2012-01-23 09:21:33 +01:00
Loïc Hoguin
b650ef8907 Merge branch 'multipart' of https://github.com/nox/cowboy
Conflicts:
	src/cowboy_http_req.erl
	test/http_SUITE.erl
2012-01-23 07:37:49 +01:00
Anthony Ramine
528507c7de Add multipart support 2012-01-23 07:20:35 +01:00
Loïc Hoguin
fd211d3c03 Fix handler crashes handling
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.
2012-01-06 20:23:59 +01:00
Yurii Rashkovskii
ade1fb93ca inet_address:parse/1 does not accept binaries as an input, only strings 2012-01-04 15:13:14 -08:00
Loïc Hoguin
bd8f31ed07 Merge branch 'static-handler-split' of https://github.com/klaar/cowboy 2012-01-03 23:39:45 +01:00
Magnus Klaar
937a2b0326 Add cowboy_http_req:set_resp_body_fun/3. 2011-12-28 18:17:10 +01:00
Magnus Klaar
612b8f21fe Add cowboy_http_req:transport/1 function. 2011-12-28 18:15:47 +01:00
Loïc Hoguin
298ba1f1bb Add 'Upgrade' header parsing
Not parsing product tokens, I don't see much point.
2011-12-22 22:10:00 +01:00
Loïc Hoguin
f390dbd606 Add meta/2 and meta/3 to cowboy_http_req to save useful protocol information
* cowboy_http_protocol now defines 'websocket_version' as metadata.
* cowboy_http_rest now defines 'media_type', 'language', 'charset' as metadata.
2011-12-19 09:44:47 +01:00
Loïc Hoguin
f9bd5d1061 Add missing p_headers and cookies to compacted values 2011-12-19 08:56:48 +01:00
Magnus Klaar
fed1410b14 update type of resp_body to iodata
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.
2011-12-16 16:29:13 +01:00
Loïc Hoguin
cc44a6a518 Merge branch 'master' of https://github.com/erlyvideo/cowboy
Just fixed the indentation a bit.
2011-12-08 19:09:05 +01:00
Max Lapshin
b9c70f2e08 peer_addr/1 function 2011-12-08 17:58:16 +03:00
Loïc Hoguin
7f46e53436 Merge branch 'noquoted' of https://github.com/klaar/cowboy 2011-12-07 19:27:06 +01:00
Magnus Klaar
c747efbd75 replace quoted:from_url with cowboy_http:urldecode
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.
2011-12-07 19:02:10 +01:00
Loïc Hoguin
ce92ab1e63 Add cowboy_http_req:set_resp_cookie/4
Pretty much just an alias for a combination of set_resp_header and cookie.
2011-12-07 11:54:57 +01:00
Loïc Hoguin
3649b0ee0d Simplify the guards for cowboy_http_req:body/2 2011-12-06 12:53:56 +01:00
Loïc Hoguin
7acaa996ed The semantics for a missing 'If-Match' aren't the same as '*' 2011-12-05 10:28:45 +01:00
Loïc Hoguin
99d8f837fe Fix specs to allow headers as iodata() and not just binary() 2011-12-05 07:54:56 +01:00
Loïc Hoguin
64a40cb479 Add set_resp_header/3 and set_resp_body/2 to cowboy_http_req
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.
2011-11-28 09:09:41 +01:00
Loïc Hoguin
dcc3d83e31 Fix default parsed values for the Accept and Accept-* headers 2011-11-24 21:35:55 +01:00
Anthony Ramine
6fa7659dbb Support 'Content-Type' in parse_header/2 2011-11-10 11:53:37 +01:00
Loïc Hoguin
2f27b046d7 Add 'If-Match' and 'If-None-Match' to parse_header/2 2011-11-09 21:41:33 +01:00
Loïc Hoguin
12b9ca3526 Fix reading the request body when Length < byte_size(Buffer) 2011-11-07 19:17:49 +01:00
Loïc Hoguin
6dbe2b2130 Add 'Accept-Language' to cowboy_http_req:parse_header/2 2011-11-07 00:53:19 +01:00
Loïc Hoguin
aba1ea4636 Add 'If-Modified-Since' and 'If-Unmodified-Since' to parse_header/2
Implementing the full HTTP-date type (RFC1123, RFC850, asctime).
2011-11-05 01:49:03 +01:00
Loïc Hoguin
aadd974f06 Merge branch 'parse_header-content-length' of https://github.com/nox/cowboy
Conflicts:
	src/cowboy_http.erl
2011-11-04 12:33:40 +01:00
Anthony Ramine
04bcbc444d Support 'Content-Length' in parse_header/2 2011-11-04 12:21:01 +01:00
Loïc Hoguin
77b3562257 Rename cowboy_http:charset/2 to conneg/2 and use it for Accept-Encoding
Sorry I apparently used an outdated RFC when I was doing this.
2011-11-04 10:38:04 +01:00
Paul Oliver
bd90df1f5e Fix cowboy_http_req:chunk/2 spec 2011-10-29 15:48:43 +01:00
Loïc Hoguin
4cd825923f Add 'Accept-Charset' to cowboy_http_req:parse_header/2 2011-10-26 20:54:21 +02:00
Loïc Hoguin
20204fd33e Add 'Accept-Encoding' to cowboy_http_req:parse_header/2 2011-10-26 19:24:49 +02:00
Loïc Hoguin
c605c4fa40 Add 'Accept' header parsing
Rework the cowboy_http_req:parse_header/2 function while I was at it.
2011-10-26 04:07:08 +02:00
Loïc Hoguin
c589922ebd Parse Connection header tokens in a case-insensitive manner 2011-10-20 19:04:49 +02:00
Loïc Hoguin
381c178073 Add a cowboy_http_req:upgrade_reply/3 function and use it for websockets
This function doesn't try to add any additional header besides the
Connection: Upgrade header. It also doesn't accept a body.

It should be used for the intermediate reply to an upgrade process,
before the real reply is sent (if any, for example when using TLS).
2011-10-20 14:11:17 +02:00
Loïc Hoguin
1e7338bdd4 Rewrite the token list parsing into separate, modulable functions
Introduce cowboy_http's list/2, nonempty_list/2, token/2 functions.
2011-10-17 10:29:14 +02:00
Loïc Hoguin
81cc99d10b Add shortcuts to reply functions
New functions are reply/2, reply/3, chunked_reply/2 in cowboy_http_req.
2011-10-13 16:16:53 +02:00
Loïc Hoguin
2a324aca3a Rename a variable from Code to Status 2011-10-13 16:01:55 +02:00
Loïc Hoguin
fd786ef233 Fix a crash in response_connection when Name is an atom =/= 'Connection' 2011-10-07 16:14:39 +02:00
Loïc Hoguin
8e835bce9f Close the connection when the application sends Connection: close
Now Cowboy checks headers sent to the client for the 'Connection'
header value, parses it, and checks whether it contains a 'close'
or 'keep-alive' value. It makes sure to close or keep the connection
alive depending on the value found there, if any.

Also change chunked replies to not close the connection by default
unless the application requests it.
2011-10-06 12:40:04 +02:00
Loïc Hoguin
97460a5993 Fix a crash in websocket_handshake when cowboy_http_req:compact/1 is used
Also add a call to compact/1 in the websocket test handler so we may
catch bugs related to it faster later on.
2011-10-06 01:07:49 +02:00