aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)Author
2011-12-07Add cowboy_http_req:set_resp_cookie/4Loïc Hoguin
Pretty much just an alias for a combination of set_resp_header and cookie.
2011-12-06Fix a crash in websocket_handshake/3 with hixie-76Loïc Hoguin
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-06Simplify the guards for cowboy_http_req:body/2Loïc Hoguin
2011-12-06cowboy_http_protocol shouldn't crash if the client sends HTTP responsesLoïc Hoguin
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-05Add experimental Webmachine based REST protocol supportLoïc Hoguin
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-05The semantics for a missing 'If-Match' aren't the same as '*'Loïc Hoguin
2011-12-05Fix specs to allow headers as iodata() and not just binary()Loïc Hoguin
2011-12-01Change the returned value for language_range parsingLoïc Hoguin
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-11-28Weekdays are binaries and not listsLoïc Hoguin
Spotted by devinus on IRC.
2011-11-28Add set_resp_header/3 and set_resp_body/2 to cowboy_http_reqLoïc Hoguin
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-24Fix default parsed values for the Accept and Accept-* headersLoïc Hoguin
2011-11-24Fix specs for cowboy_http:language_range_ret/3Loïc Hoguin
2011-11-10Support 'Content-Type' in parse_header/2Anthony Ramine
2011-11-10Introduce cowboy_http:media_type/2Anthony Ramine
2011-11-10Introduce cowboy_http:word/2Anthony Ramine
Used to parse either a token or a quoted string in parameters values.
2011-11-09Add 'If-Match' and 'If-None-Match' to parse_header/2Loïc Hoguin
2011-11-07Fix reading the request body when Length < byte_size(Buffer)Loïc Hoguin
2011-11-07Add 'Accept-Language' to cowboy_http_req:parse_header/2Loïc Hoguin
2011-11-05Remove the IS_DIGIT macroLoïc Hoguin
2011-11-05Add 'If-Modified-Since' and 'If-Unmodified-Since' to parse_header/2Loïc Hoguin
Implementing the full HTTP-date type (RFC1123, RFC850, asctime).
2011-11-04Merge branch 'parse_header-content-length' of https://github.com/nox/cowboyLoïc Hoguin
Conflicts: src/cowboy_http.erl
2011-11-04Support 'Content-Length' in parse_header/2Anthony Ramine
2011-11-04Remove unneeded whitespaces according to the HTTP specLoïc Hoguin
2011-11-04Rename cowboy_http:charset/2 to conneg/2 and use it for Accept-EncodingLoïc Hoguin
Sorry I apparently used an outdated RFC when I was doing this.
2011-11-01Merge branch 'chrome-15' of https://github.com/puzza007/cowboyLoïc Hoguin
2011-11-01Set the cowboy_listener process priority to highLoïc Hoguin
See comment added with it for more information.
2011-10-30update record spec for version 13Paul Oliver
2011-10-29Fix cowboy_http_req:chunk/2 specPaul Oliver
2011-10-28fix supervisor spec for non dynamic modulesSteven Gravell
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-26Add 'Accept-Charset' to cowboy_http_req:parse_header/2Loïc Hoguin
2011-10-26Rename private function quality/2 into qvalue/2Loïc Hoguin
2011-10-26cowboy_http:media_range/2 should expect to not have whitespace before itLoïc Hoguin
2011-10-26Add 'Accept-Encoding' to cowboy_http_req:parse_header/2Loïc Hoguin
2011-10-26Add 'Accept' header parsingLoïc Hoguin
Rework the cowboy_http_req:parse_header/2 function while I was at it.
2011-10-25Rewrite list/tokens parsing with an added whitespace functionLoïc Hoguin
2011-10-24Make sure the correct callback name is displayed in websocket errorsLoïc Hoguin
2011-10-24Accept Sec-WebSocket-Version: 13 header on Chrome 15 through 17Paul Oliver
2011-10-24We don't need to retrieve the Origin header for hybi-7+ websocket draftsLoïc Hoguin
2011-10-20Parse Connection header tokens in a case-insensitive mannerLoïc Hoguin
2011-10-20Add a cowboy_http_req:upgrade_reply/3 function and use it for websocketsLoïc Hoguin
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"websocket" must be treated in a case insensitive manner for upgradesLoïc Hoguin
Fixed according to the websocket draft specs.
2011-10-20Make sure the hixie-76 websocket code works properly with proxiesLoïc Hoguin
2011-10-19Add a max_line_length to the HTTP protocolLoïc Hoguin
Allows to limit the size of request and header lines, thus preventing Cowboy from infinitely reading from the socket and never finding an end of line. Defaults to 4096 bytes.
2011-10-17Rewrite the token list parsing into separate, modulable functionsLoïc Hoguin
Introduce cowboy_http's list/2, nonempty_list/2, token/2 functions.
2011-10-13Add shortcuts to reply functionsLoïc Hoguin
New functions are reply/2, reply/3, chunked_reply/2 in cowboy_http_req.
2011-10-13Rename a variable from Code to StatusLoïc Hoguin
2011-10-11Fix a misnamed variable for {loop, ...} returns in init/3Loïc Hoguin
2011-10-11Fix specs after erlang:hibernate/3 calls were addedLoïc Hoguin
This however does not fix the related Dialyzer warnings. I have no idea what the warnings are about nor how to fix them, so feel free to work on it and submit a patch!
2011-10-10Add support for loops in standard HTTP handlersLoïc Hoguin
Now init/3 can return one of the following values to enable loops: - {loop, Req, State} - {loop, Req, State, hibernate} - {loop, Req, State, Timeout} - {loop, Req, State, Timeout, hibernate} Returning one of these tuples will activate looping in the HTTP handler. When looping, handle/2 is never called. Instead, Cowboy will listen for Erlang messages and forward them to the info/3 function of the handler. If a timeout is defined, Cowboy will also close the connection when no message has been received for Timeout milliseconds. The info/3 function is defined as info(Msg, Req, State). It can return either of the following tuples: - {ok, Req, State} - {loop, Req, State} - {loop, Req, State, hibernate} The first one ends the connection, calling terminate/2 before closing. The others continue the loop. Loops are useful when writing long-polling handlers that need to wait and don't expect to receive anything. Therefore it is recommended to set a timeout to close the connection if nothing arrives after a while and to enable hibernate everywhere. Normal HTTP handlers shouldn't need to use this and as such info/3 was made optional.
2011-10-10Add {shutdown, Req} to websocket_init/3 to fail a websocket upgradeLoïc Hoguin
This change allows application developers to refuse websocket upgrades by returning {shutdown, Req}. The application can also send a reply with a custom error before returning from websocket_init/3, otherwise an error 400 is sent. Note that right now Cowboy closes the connection immediately. Also note that neither terminate/3 nor websocket_terminate/3 will be called when the connection is shutdown by websocket_init/3.