aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)Author
2017-02-18Allow passing options to sub protocolsLoïc Hoguin
Before this commit we had an issue where configuring a Websocket connection was simply not possible without doing magic, adding callbacks or extra return values. The init/2 function only allowed setting hibernate and timeout options. After this commit, when switching to a different type of handler you can either return {module, Req, State} or {module, Req, State, Opts} where Opts is any value (as far as the sub protocol interface is concerned) and is ultimately checked by the custom handlers. A large protocol like Websocket would accept only a map there, with many different options, while a small interface like loop handlers would allow passing hibernate and nothing else. For Websocket, hibernate must be set from the websocket_init/1 callback, because init/2 executes in a separate process. Sub protocols now have two callbacks: one with the Opts value, one without. The loop handler code was largely reworked and simplified. It does not need to manage a timeout or read from the socket anymore, it's the job of the protocol code. A lot of unnecessary stuff was therefore removed. Websocket compression must now be enabled from the handler options instead of per listener. This means that a project can have two separate Websocket handlers with different options. Compression is still disabled by default, and the idle_timeout value was changed from inifnity to 60000 (60 seconds), as that's safer and is also a good value for mobile devices.
2017-02-05Remove or fix a small number of todo commentsLoïc Hoguin
One had the todo text fixed, another had the task to do done.
2017-02-05Add missing human-readable errors for HTTP/1.1Loïc Hoguin
2017-02-05Fix sending of large files with HTTP/2Loïc Hoguin
Also finish implementing the relevant test, getting rid of todos.
2017-01-24cowboy_static: Add support for files in EZ archivesJean-Sébastien Pédron
If cowboy_static is initialized with `{priv_file, ...}` or `{priv_dir, ...}`, it is now able to read files from Erlang application .ez archives. When serving a file from an archive, the #file_info{} comes from the archive, not the contained file, except for the size and type. The erl_prim_loader module is used to read the latter's #file_info{} and the actual file content (ie. sendfile(2) is not used in this case).
2017-01-22Add experimental cowboy_compress_h stream handlerLoïc Hoguin
Currently marked as experimental because it can't be tweaked (just enabled/disabled) and because it is not documented yet.
2017-01-20Fix error responses not including a content-lengthLoïc Hoguin
This would prevent the client from knowing whether the request was received fully without the connection closing first.
2017-01-20Fix protocol breaking when user tries to send empty chunkLoïc Hoguin
The {data, IsFin, Data} uses IsFin to indicate whether this is the last chunk, while chunked transfer-encoding uses the length of Data, and ends when it is 0. We must therefore not send chunks with empty data.
2017-01-16Add support for multiple stream handlersLoïc Hoguin
The stream handlers can be specified using the protocol option 'stream_handlers'. It defaults to [cowboy_stream_h]. The cowboy_stream_h module currently does not forward the calls to further stream handlers. It feels like an edge case; usually we'd want to put our own handlers between the protocol code and the request process. I am therefore going to focus on other things for now. The various types and specifications for stream handlers have been updated and the cowboy_stream module can now be safely used as a behavior. The interface might change a little more, though. This commit does not include tests or documentation. They will follow separately.
2017-01-04Make the new cowboy_req tests more realistic2.0.0-pre.5Loïc Hoguin
2017-01-04Add functions for getting and setting response headersJohan Lövdahl
2017-01-03Return status 431 if the request header field is too largeJosé Valim
This commit changes Cowboy to follow RFC6585.
2017-01-02Welcome to 2017Loïc Hoguin
2017-01-02Remaining Dialyzer fixesLoïc Hoguin
2017-01-02Numerous Dialyzer fixesLoïc Hoguin
2016-10-18Fix if_modified_since match of last_modifiedChristopher Adams
Correct expected return type from `no_call` to `undefined` in if_modified_since when last_modified callback is not defined. Add an http_SUITE test to catch regressions.
2016-08-15Send many frames in one TCP sendLoïc Hoguin
Includes refactoring of the related code to avoid repetition.
2016-08-15Allow websocket_init/1 to reply/close/hibernateLoïc Hoguin
2016-08-15Modernize the Websocket test suiteLoïc Hoguin
2016-08-12Remove Req from the Websocket interfaceLoïc Hoguin
After the switch to Websocket, we are no longer in a request/response scenario, therefore a lot of the cowboy_req functions do not apply anymore. Any data required from the request will need to be taken from Req in init/2 and saved in the handler's state.
2016-08-12Add missing specs to an internal cowboy_req functionLoïc Hoguin
2016-08-12Merge branch 'master' of https://github.com/camshaft/cowboyLoïc Hoguin
2016-08-12Fix Websocket compressionLoïc Hoguin
The option for enabling Websocket compression has been renamed. Previously it was shared with HTTP compression, now it's specific to Websocket. The new option is named 'websocket_compress'.
2016-08-11Use cow_http_hd:parse_host directlyLoïc Hoguin
Removes some duplicate code from cowboy_http.
2016-08-11Use integer_to_binary when possibleLoïc Hoguin
2016-08-11Fix timer-sent events in the websocket exampleLoïc Hoguin
2016-08-10Add specs for the cowboy_req:push/3,4 functionsLoïc Hoguin
2016-08-10Use binary_to_integer instead of to list and backLoïc Hoguin
2016-08-10Let the stream handler take care of crash handling and loggingLoïc Hoguin
2016-08-10Make reply functions return ReqLoïc Hoguin
2016-08-10Update the multipart reading interfaceLoïc Hoguin
Now named read_part/read_part_body, with a verb indicating action.
2016-08-10Remove logic to always send a response in cowboy_loopLoïc Hoguin
This is taken care of at the protocol level now.
2016-08-10Add a lot of todosLoïc Hoguin
2016-08-10Add tests for responses and request body readingLoïc Hoguin
This is a large commit. The cowboy_req interface has largely changed, and will change a little more. It's possible that some examples or tests have not been converted to the new interface yet. The documentation has not yet been updated. All of this will be fixed in smaller subsequent commits. Gotta start somewhere...
2016-06-27send resp_headers with websocket responsesCameron Bytheway
2016-06-22Remove cowboy_req:get and setLoïc Hoguin
2016-06-22Remove cowboy_req:append_buffer/2Loïc Hoguin
2016-06-22Remove unused local function in cowboy_reqLoïc Hoguin
2016-06-22Remove cowboy_req:set_bindings/4Loïc Hoguin
2016-06-22Remove cowboy_req:lock/1Loïc Hoguin
2016-06-22Remove cowboy_req:to_list/1Loïc Hoguin
2016-06-21Remove the meta functions from cowboy_reqLoïc Hoguin
Now that we have a public map they are pretty much pointless.
2016-06-21Add cowboy_req:uri/1,2Loïc Hoguin
Along with more cowboy_req tests. This commit also removes cowboy_req:url/1 and cowboy_req:host_url/1 in favor of the much more powerful new set of functions.
2016-06-21Remove cowboy_req:new/14Loïc Hoguin
This internal function is no longer necessary.
2016-06-20Add cowboy_req:scheme/1Loïc Hoguin
2016-06-20Properly parse the host/port in HTTP/2Loïc Hoguin
2016-06-20Fix cowboy_req:peer/1Loïc Hoguin
2016-06-16Make sure a response is always sent with HTTP/2Loïc Hoguin
Previously only DATA was sent, with missing HEADERS.
2016-06-13Fix streaming HTTP/2 responsesLoïc Hoguin
Error reporting for connection processes has been improved, using a similar proc_lib hack as was done for the stream processes.
2016-06-08Fix request body reading in HTTP/2Loïc Hoguin