aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_websocket.erl
AgeCommit message (Collapse)Author
2014-07-12Drop R15 supportLoïc Hoguin
2014-07-12Reply with 400 on header parsing crashLoïc Hoguin
This is a first step to improve the HTTP status codes returned by Cowboy on crashes. We will tweak it over time. Also fixes a small bug where two replies may have been sent when using loop handlers under rare conditions.
2014-06-30Update specs that were too wideLoïc Hoguin
2014-03-26Remove outdated comments, all edoc, plus a few minor tweaksLoïc Hoguin
2014-03-08Fix typespecs of cowboy_websocket:handler_terminateLoïc Hoguin
Pointed out during the ConcuError tutorial by Kostis. Thanks! :-)
2014-02-06Update copyright yearsLoïc Hoguin
2013-08-27Merge branch 'fix-ws-atom-responses' of git://github.com/seriyps/cowboyLoïc Hoguin
2013-08-27Merge branch 'websocket-compressed-metadata' of git://github.com/irccloud/cowboyLoïc Hoguin
2013-08-24Crash on failure, don't report errorsLoïc Hoguin
When something went wrong in a handler we used to report errors and then terminate the process normally. This doesn't work so well with links which won't detect failure. Now we still catch the error, but throw another one with more details on why it happened, including the Req object information and the stacktrace. Ranch will then print an error message with all this information. Because we crash directly, this also means that we will not hog resources unnecessarily for too long when something bad happens.
2013-08-15add websocket_compress metadataRJ
2013-08-13Allow atom responses in websocket handlers #563Sergey Prokhorov
2013-07-08Use the proper typespec for the websocket_deflate_frame rsv bitsAli Sabil
2013-07-02Fix handling of websocket fragmented deflated framesAli Sabil
2013-07-02Fix websocket unmasking when compression is enabledAli Sabil
The unmasking logic was based on the length of inflated data instead of the length of the deflated data. This meant data would get corrupted when we receive a websocket frame split across multiple TCP packets.
2013-07-02Fix coding style in websocket_deflate_frame/3Ali Sabil
2013-07-02Remove usage of the inflate bufferAli Sabil
2013-06-20Fix compilation < R16B010.8.6Loïc Hoguin
2013-06-20Ignore deprecation warning for crypto:sha/1 for nowLoïc Hoguin
We can change this call when we start supporting only R16B+, which may happen when R17B is released or some time before.
2013-06-20Add support for the webkit deflate frame extensionAli Sabil
2013-05-15Fix the cowboy_websocket:frame/0 typeLoïc Hoguin
It accepts iodata() and not binary() for the payload.
2013-04-03Update Ranch to 0.8.0Loïc Hoguin
2013-02-16Add sub protocol behaviourJames Fish
2013-02-14Properly pass the handler's state to websocket_terminate/3 on closeLoïc Hoguin
2013-02-13Make cowboy_websocket.erl compile with +nativeAdam Cammack
Worked until cccc0bc
2013-02-09Do not reset the connection timeout timer on sendLoïc Hoguin
Sends can be successful even if the connection is gone.
2013-01-29Fix {cowboy_req, resp_sent} potentially leaking in loop handlersLoïc Hoguin
2013-01-17Add cowboy_websocket:close_code/0Loïc Hoguin
Also fixes a warning.
2013-01-14Improve websocket close handlingLoïc Hoguin
We now always send a failure reason (bad protocol, bad encoding, etc.) unless the closure was initiated by the client and it didn't send a close code. We now check that the close frames have a payload that is valid UTF-8, unless they don't have a payload at all. We now do not crash the process anymore when bad opcodes are sent, or when the opcode 0 is sent before fragmentation was initiated. Overall this makes us closer to full compliance with the RFC.
2013-01-13Websocket text frames are now checked for UTF-8 correctnessLoïc Hoguin
The autobahntestsuite now passes 100% of the tests. We are getting close to fully implementing the Websocket RFC.
2013-01-12Unmask websocket frames on the fly and optimize the codeLoïc Hoguin
No change in functionality, but this will allow us to validate that text frames are utf8 without having to receive the frame entirely.
2013-01-12All frames sent from client to server MUST be maskedLoïc Hoguin
Good in theory, but implementations may vary. If something stops working after this commit we might need some tweaks to support existing clients. Please try it and give feedback.
2013-01-10Remove support for Websocket hixie76 draftLoïc Hoguin
It was only used by Safari 5.0.1 and possibly 5.1. Their market share is dropping as we speak. It was also insecure (disabled in Firefox for that reason). This will allow us to make much more efficient and cleaner code for the rest of the Websocket versions we support (drafts 7 to 17 + RFC), which are pretty much all versions seen in the wild excluding the one we're removing here.
2013-01-05Remove cowboy_req:transport/1Loïc Hoguin
It was added to help with response body streaming functions. But it was a clumsy solution that we discarded in favor of passing socket and transport to said function. It was also very odd compared to the rest of the cowboy_req interface. If you used this function before, worry not, here's its proper equivalent. [Socket, Transport] = cowboy_req:get([socket, transport], Req)
2013-01-03Add middleware supportLoïc Hoguin
Middlewares allow customizing the request processing. All existing Cowboy project are incompatible with this commit. You need to change `{dispatch, Dispatch}` in the protocol options to `{env, [{dispatch, Dispatch}]}` to fix your code.
2012-12-22Cancel timer only on websocket_data receives or sendsJeremy Ong
This commit prevents erlang messages from keeping a websocket connection alive. Previously, the timer was canceled upon any activity. Now, the timeout is only canceled when actual data is sent from the client. The handler_loop_timeout/1 function is called from websocket_data/4 instead of handler_before_loop/4. It is also called after every successful reply in handler_call/4.
2012-12-13Make the arguments to error_logger more consistentAndrew Thompson
The purpose of this patch is to make the arguments cowboy passes to error_logger more consistent. With this patch there's only 3 variations on the error_logger argument list; a 5 element list, an 8 element list and a 10 element list. In all cases, the first 3 arguments are the Module, Function and Arity of the function being called and the second-to-last argument is always the Request. Additionally, for lists longer than 5 elements, the last argument is always the stack-trace. The added consistency of the argument ordering makes it much easier to write code in lager's error_logger handler to catch these messages and write a pretty one-liner (while writing the full message to the crash.log).
2012-12-08Add {close, StatusCode, Payload} and fix {close, Payload}Loïc Hoguin
2012-12-07Merge branch 'websocket_terminate_not_called' of git://github.com/dergraf/cowboyLoïc Hoguin
2012-12-06call websocket_terminate in case of a handshake errorAndre Graf
2012-12-05Make a few more missing headers lowercaseLoïc Hoguin
2012-12-02Add more frame types available in websocket repliesLoïc Hoguin
We can now reply empty close, ping and pong frames, or close frames with a payload. This means that we can send a frame and then close the connection in a single operation. If a close packet is sent, the connection is closed immediately, even if there was frames that remained to be sent. Cowboy will silently drop any extra frames in the list given as a reply.
2012-11-28Clarify error reports indicating they come from CowboyLoïc Hoguin
2012-11-27Check for errors when calling Transport:send in the websocket protocolAli Sabil
In some situations, the underlying socket might become "half-open" in which case the websocket will stay in a waiting state indefinitely. The detection of this state requires checking for errors when calling send.
2012-10-11Allow websocket handlers to reply more than one frameLoïc Hoguin
Instead of returning {text, Data}, you can now return [{text, Data}, {text, Data2}, ...].
2012-10-11Add crypto into the required applicationsLoïc Hoguin
As suggested by @prof3ta.
2012-09-21Don't use decode_packet/3 for parsing the headersLoïc Hoguin
Header names are now binaries. Since header names are case insensitive they are all converted to lowercase. For example: <<"content-length">>. The max_line_length option was removed. Three new options have been added instead: * max_request_line_length (defaults to 4096) * max_header_name_length (defaults to 64) * max_header_value_length (defaults to 4096)
2012-09-17Improve consistency of return types for cowboy_req APILoïc Hoguin
The signature of parse_header, body_qs, multipart_data and the set_resp_* functions has changed. See the cowboy_req module edoc for more details.
2012-09-15Introduce cowboy_req:set_meta/3 to set request metadataLoïc Hoguin
2012-09-15Remove duplicate code for ensure_responseLoïc Hoguin
2012-09-15Add cowboy_req:url/1 to return the full request URLLoïc Hoguin
Use it in cowboy_websocket for hixie76, replacing http by ws.