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

27 commits

Author SHA1 Message Date
Loïc Hoguin
0c2e2224e3 Update version to 0.6.0
Also update the CHANGELOG and copyright years.
2012-05-23 14:53:48 +02:00
Magnus Klaar
5a7040ee1c Convert request to proplist when logging 2012-04-01 17:57:00 +02:00
Loïc Hoguin
e87f51e542 Merge branch 'content-type-accepted-asterisk-atom' of https://github.com/dysinger/cowboy
Added a comment explaining the '*' always matching.
2012-03-13 01:43:15 +01:00
Tim Dysinger
21cd61cb38 If we have a mapping to '*' then use it as the default catch all accept 2012-03-08 03:17:55 -10:00
Magnus Klaar
9922de6d9e Tests and fixes for the generate_etag/2 callback
The return value from the generate_etag/2 callback is expected to be a
binary tagged with either weak or strong. This binary is quoted, and
may be prefixed with W/ before it is set as the value of the ETag header
in the response.

For backwards compatibility with older handlers where the return value
was expected to be a quoted binary a function has been added to parse any
return values that are untagged binaries. All untagged binaries are expected
to be a valid value for the ETag header.
2012-02-29 22:32:37 +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
f6cf731011 REST: Only send 201 when a new resource is created on POST 2012-02-20 08:33:54 +01:00
Tom Burdick
ca42ea1620 Handle delete better when no delete_resource function is implemented 2012-01-26 18:21:20 +01:00
Loïc Hoguin
dee19f11c3 Add {halt, Req, State} return value to most REST callbacks
Excluding generate_etag, last_modified, expires and variances.
2012-01-23 08:24:15 +01:00
Loïc Hoguin
0761ef67a1 Rename a lot of HandlerState2 variables to HandlerState 2012-01-23 08:11:29 +01:00
Loïc Hoguin
3078e94db6 Improve the return value for cowboy_http_rest:upgrade/4 2012-01-23 07:55:08 +01:00
Loïc Hoguin
fed6727634 Make REST handlers' put_resource accept true or false return values
Followup to 0bb23f2400.
As discussed in #119.
2012-01-09 08:06:05 +01:00
Loïc Hoguin
0bb23f2400 Make REST handlers' process_post accept true or false return values
They should return true when it has been processed successfully,
or false otherwise, in which case a 500 error is sent.

Fixes #119.
2012-01-06 21:05:58 +01:00
Magnus Klaar
f56479ffc2 Add cowboy_http_req:set_resp_body_fun/3 to rest 2011-12-28 18:17:15 +01:00
Loïc Hoguin
156c84ff29 Use calendar date and time types exported since R14B04
Removes the cowboy_clock:date/0, time/0 and datetime/0 exported types.
2011-12-26 10:17:29 +01:00
Loïc Hoguin
17c9d45786 Remove outdated @todo notes and update another 2011-12-22 21:48:24 +01:00
Loïc Hoguin
c54c361adb create_path now returns a path, not an URI
Also add the new 'put_path' metadata information to the request
before entering the put_resource step (which proceeds to call
content_types_accepted and then the chosen content type's callback,
which is expected to use the 'put_path' value as the path to the new
resource instead of the original request path, because it may have
been changed by the create_path call.
2011-12-19 10:29:44 +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
874cdd3bda Merge branch 'variances-fix' of github.com:klaar/cowboy 2011-12-12 08:23:34 +01:00
Loïc Hoguin
f445f16f60 Fixes match_media_type in cowboy_http_rest
Based on the patch from Heinz N. Gies. The main change is that his
patch accept values such as */plain which we do not want.

Fixes issue #105.
2011-12-12 08:21:18 +01:00
alisdair sullivan
62bdb7d9a2 adds webmachine format content type handling 2011-12-12 07:46:35 +01:00
Magnus Klaar
2644a6cacc update cowboy_http_rest:variances/2
Fix pattern in case statement that was intended
to strip away the first comma separating the
values in the variance header.

Update generation of variance list to use more
idiomatic erlang. Pattern match on list structure
over using erlang:length/1 to compute length.
2011-12-11 19:57:07 +01:00
Loïc Hoguin
168405830d Fix the process_post/2 function in cowboy_http_rest 2011-12-08 20:21:50 +01:00
Loïc Hoguin
81fe0592b1 Add more documentation to the REST protocol handler 2011-12-08 20:16:04 +01:00
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
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