0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 12:40:25 +00:00
Commit graph

286 commits

Author SHA1 Message Date
Loïc Hoguin
1530d45f8e Add default values to known_methods and allowed_methods
Only allowing HEAD and GET requests by default.
2011-12-08 18:54:20 +01:00
Loïc Hoguin
8d2102fe11 Allow HTTP protocol upgrades to use keepalive
REST needed this to be allowed to chain requests on the same connection.
2011-12-08 18:30:13 +01: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
a12a910341 Fix a crash in websocket_handshake/3 with hixie-76
Happened when an error occurred while trying to read the body to
get the key. Also fixes all the dialyzer warnings in cowboy_http_websocket.
2011-12-06 12:54:09 +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
0201f7f2b2 cowboy_http_protocol shouldn't crash if the client sends HTTP responses
It was replying back the correct error, but with a crash message in
the console. This patch prevents it from crashing.

Fixes issue #94 reported by oribrost.
2011-12-06 12:22:36 +01:00
Loïc Hoguin
aab1587a4b Add experimental Webmachine based REST protocol support
As with everything experimental, it probably has a lot of bugs and
may not even work.

Like Websocket, REST must be upgraded from a standard resource through
the init/3 function.

A key difference between Webmachine and Cowboy's REST protocol handler
is that in Cowboy the resource has direct access to the request object.
This makes a small change in a few places where you were expected to
return headers or body in Webmachine and are now expected to set them
directly yourself if needed (options/2, for example).

Another difference is that the functions rest_init/2 will always be
called when starting to process a request. Similarly, rest_terminate/2
will be called when the process completes successfully.

The Cowboy REST support also includes automatic language selection,
thanks to the languages_provided/2 callback.

Finally, Cowboy REST expects full URIs to be given at all times, and
will not try to reconstruct URIs from fragments.

Note that REST requests cannot be chained (keepalive) at this time.
This is a design issue in cowboy_http_protocol that will be fixed soon.

Check out the source for more details. It has been designed to be very
easy to read and understand so if you don't understand something,
it's probably a bug. Thanks in advance for all the great bug reports,
pull requests and comments you'll forward my way!
2011-12-05 23:05:32 +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
83ec63374f Change the returned value for language_range parsing
Considering how it must be used, a simple binary is much better
than a tag and a list of subtags. We still parse them like this
to make sure they follow the specs, though.
2011-12-01 20:38:38 +01:00
Loïc Hoguin
2ae5e804fb Weekdays are binaries and not lists
Spotted by devinus on IRC.
2011-11-28 21:18:03 +01:00
Loïc Hoguin
ad87fee0af Fix a websocket test handler that was throwing an unwanted error
The test still worked because we expect the websocket connection
to fail, but it didn't fail exactly the way we wanted it to.
2011-11-28 09:14:07 +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
Loïc Hoguin
f1c94c40f8 Fix specs for cowboy_http:language_range_ret/3 2011-11-24 21:32:27 +01:00
Loïc Hoguin
a5b47fda8d Merge branch 'content-type' of https://github.com/nox/cowboy 2011-11-10 12:55:00 +01:00
Anthony Ramine
6fa7659dbb Support 'Content-Type' in parse_header/2 2011-11-10 11:53:37 +01:00
Anthony Ramine
b184b3588d Introduce cowboy_http:media_type/2 2011-11-10 11:03:22 +01:00
Anthony Ramine
329b2fa01e Introduce cowboy_http:word/2
Used to parse either a token or a quoted string in parameters values.
2011-11-10 11:03:21 +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
3e443f0a6c Remove the IS_DIGIT macro 2011-11-05 03:23:21 +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
a118f53c74 Remove unneeded whitespaces according to the HTTP spec 2011-11-04 11:58:45 +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
Loïc Hoguin
68c1d886e5 Merge branch 'chrome-15' of https://github.com/puzza007/cowboy 2011-11-01 15:55:40 +01:00
Loïc Hoguin
3ce2865d84 Set the cowboy_listener process priority to high
See comment added with it for more information.
2011-11-01 15:53:51 +01:00
Paul Oliver
89752a2769 update record spec for version 13 2011-10-30 11:22:12 +00:00
Loïc Hoguin
774659ec03 Merge branch 'chunk-spec' of https://github.com/puzza007/cowboy 2011-10-30 01:32:40 +02:00
Paul Oliver
bd90df1f5e Fix cowboy_http_req:chunk/2 spec 2011-10-29 15:48:43 +01:00
Loïc Hoguin
d9da5334d2 Merge branch 'supervisor-relup-fix' of https://github.com/smarkets/cowboy 2011-10-28 18:09:09 +02:00
Steven Gravell
1af77d45e3 fix supervisor spec for non dynamic modules
a release upgrade on a vm running cowboy where any other appup
includes an {update, Mod, {advanced, Extra}} instruction will hang
forever due to these child specs being wrong.

The gen_servers should be [Mod] and the non gen_server needs to be []
since there is no callback to handle this.
2011-10-28 16:44:46 +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
819eb219e7 Rename private function quality/2 into qvalue/2 2011-10-26 20:13:36 +02:00
Loïc Hoguin
725e272996 cowboy_http:media_range/2 should expect to not have whitespace before it 2011-10-26 19:41:49 +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
1a839954bb Rewrite list/tokens parsing with an added whitespace function 2011-10-25 10:29:46 +02:00
Loïc Hoguin
6223018212 Merge pull request #79 from athoune/patch-1
Update README.md
2011-10-24 21:37:20 -07:00
Mathieu Lecarme
3ba578d5e4 Update README.md 2011-10-25 00:05:31 +03:00
Loïc Hoguin
30a1d13ae9 Make sure the correct callback name is displayed in websocket errors 2011-10-24 17:06:16 +02:00
Loïc Hoguin
d7eec7d8c3 Merge branch 'chrome-15' of https://github.com/puzza007/cowboy 2011-10-24 16:27:14 +02:00
Paul Oliver
30c3c75bbc Accept Sec-WebSocket-Version: 13 header on Chrome 15 through 17 2011-10-24 15:23:36 +01:00
Loïc Hoguin
f990109af6 We don't need to retrieve the Origin header for hybi-7+ websocket drafts 2011-10-24 10:11:09 +02:00
Loïc Hoguin
c589922ebd Parse Connection header tokens in a case-insensitive manner 2011-10-20 19:04:49 +02:00