0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00
Commit graph

521 commits

Author SHA1 Message Date
Magnus Klaar
f56479ffc2 Add cowboy_http_req:set_resp_body_fun/3 to rest 2011-12-28 18:17:15 +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
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
52c177fa6f Add CHANGELOG.md file 2011-12-26 08:40:18 +01:00
Loïc Hoguin
3d5f02af0e Update AUTHORS file 2011-12-22 22:18:19 +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
17c9d45786 Remove outdated @todo notes and update another 2011-12-22 21:48:24 +01:00
Loïc Hoguin
72d91583b9 Add a max_keepalive HTTP protocol option
Based on the patch by Louis-Philippe Gauthier.
2011-12-22 21:35:40 +01:00
Loïc Hoguin
eea6b2ab80 Websocket control frames payload length must be lower than 126 bytes 2011-12-22 21:00:09 +01:00
Loïc Hoguin
7a68a38e5a Add ct tests for binary websocket frames 2011-12-22 20:19:05 +01:00
Loïc Hoguin
9800348c21 Move the websocket tests in a separate suite 2011-12-22 20:06:58 +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
f9bd5d1061 Add missing p_headers and cookies to compacted values 2011-12-19 08:56:48 +01:00
Loïc Hoguin
740931131b Merge branch 'resp-body-fix' of github.com:klaar/cowboy 2011-12-17 13:24:54 +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
621411350a Remove -Wbehaviours dialyzer option unavailable in R15B 2011-12-16 01:26:19 +01:00
Loïc Hoguin
a7a6faf91e Skip dependencies when running ct tests 2011-12-15 20:47:08 +01:00
Loïc Hoguin
ce7084aa07 Fix a dialyzer warning 2011-12-15 20:45:12 +01:00
Loïc Hoguin
f81cb89b54 Reply status 400 if we receive an unexpected value or error for headers 2011-12-15 20:43:15 +01:00
Loïc Hoguin
e550ba7cd3 Add cowboy:accept_ack/1 for a cleaner handling of the shoot message 2011-12-15 20:19:02 +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
Loïc Hoguin
a37dd714e0 Merge branch 'hipe-compilation-fix' of github.com:klaar/cowboy 2011-12-12 07:54:56 +01:00
Loïc Hoguin
7c1372df20 Merge branch 'master' of github.com:talentdeficit/cowboy 2011-12-12 07:47:08 +01:00
alisdair sullivan
62bdb7d9a2 adds webmachine format content type handling 2011-12-12 07:46:35 +01:00
Loïc Hoguin
57eb99fa42 Merge branch 'urlencode' of github.com:klaar/cowboy 2011-12-12 07:20:23 +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
Magnus Klaar
b1bbd023c5 update /bits in binary expressions to /binary
This is a workaround for an issue in the hipe compiler where
compilation of code matching on binaries using patterns of the
form Data = <<Char, _Ignore/bits>> fails because _Ignore is
expected to be used. Using /binary instead of /bits resolves
the issue.

We're applying this change to all binary expressions in cowboy_http
because all functions in this module process human readable text
formats which are always expected to be bytestrings.

Two uses of /bits has been changed to /binary in cowboy_http_websocket
in two clauses of a single function, websocket_data/4. This is safe
to change because the data is later passed to binary:match/2 which
will always fail with a badarg error if the input is a bitstring
instead of a bytestring.
2011-12-10 18:33:09 +01:00
Magnus Klaar
ef7b41c8ce add cowboy_http:urlencode/2 and urlencode/1
This function complements the cowboy_http:urldecode/2
and urldecode/1 functions. We should have this encoding
covered now. urldecode is only expected to be invoked
by user code, no further changes needed to integrate this.
2011-12-09 21:38:04 +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
cc44a6a518 Merge branch 'master' of https://github.com/erlyvideo/cowboy
Just fixed the indentation a bit.
2011-12-08 19:09:05 +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
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
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