{"action":"created","issue":{"url":"https://api.github.com/repos/servo/servo/issues/7860","labels_url":"https://api.github.com/repos/servo/servo/issues/7860/labels{/name}","comments_url":"https://api.github.com/repos/servo/servo/issues/7860/comments","events_url":"https://api.github.com/repos/servo/servo/issues/7860/events","html_url":"https://github.com/servo/servo/issues/7860","id":109715545,"number":7860,"title":"Clean up websocket closing code","user":{"login":"jdm","id":27658,"avatar_url":"https://avatars.githubusercontent.com/u/27658?v=3","gravatar_id":"","url":"https://api.github.com/users/jdm","html_url":"https://github.com/jdm","followers_url":"https://api.github.com/users/jdm/followers","following_url":"https://api.github.com/users/jdm/following{/other_user}","gists_url":"https://api.github.com/users/jdm/gists{/gist_id}","starred_url":"https://api.github.com/users/jdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdm/subscriptions","organizations_url":"https://api.github.com/users/jdm/orgs","repos_url":"https://api.github.com/users/jdm/repos","events_url":"https://api.github.com/users/jdm/events{/privacy}","received_events_url":"https://api.github.com/users/jdm/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/servo/servo/labels/A-content/dom","name":"A-content/dom","color":"d7e102"},{"url":"https://api.github.com/repos/servo/servo/labels/C-assigned","name":"C-assigned","color":"02d7e1"},{"url":"https://api.github.com/repos/servo/servo/labels/E-less%20easy","name":"E-less easy","color":"02e10c"},{"url":"https://api.github.com/repos/servo/servo/labels/I-refactor","name":"I-refactor","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-10-05T00:38:55Z","updated_at":"2016-01-12T01:33:45Z","closed_at":null,"body":"The code in `websocket.rs` related to closing the connection is difficult to read and reason about for a number of reasons. I propose the following:\r\n* we add a method named `close_the_websocket_connection` which creates a `CloseTask` and dispatches it to the script event loop\r\n* document that `CloseTask` implements the steps [described in the spec](https://html.spec.whatwg.org/multipage/comms.html#closeWebSocket)\r\n* move the fields of WebSocket that are only used by CloseTask into CloseTask (such as `reason`, `clean_close`, `code`, etc.) and add constructors with meaningful names as appropriate"},"comment":{"url":"https://api.github.com/repos/servo/servo/issues/comments/170753703","html_url":"https://github.com/servo/servo/issues/7860#issuecomment-170753703","issue_url":"https://api.github.com/repos/servo/servo/issues/7860","id":170753703,"user":{"login":"jsanders","id":38320,"avatar_url":"https://avatars.githubusercontent.com/u/38320?v=3","gravatar_id":"","url":"https://api.github.com/users/jsanders","html_url":"https://github.com/jsanders","followers_url":"https://api.github.com/users/jsanders/followers","following_url":"https://api.github.com/users/jsanders/following{/other_user}","gists_url":"https://api.github.com/users/jsanders/gists{/gist_id}","starred_url":"https://api.github.com/users/jsanders/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsanders/subscriptions","organizations_url":"https://api.github.com/users/jsanders/orgs","repos_url":"https://api.github.com/users/jsanders/repos","events_url":"https://api.github.com/users/jsanders/events{/privacy}","received_events_url":"https://api.github.com/users/jsanders/received_events","type":"User","site_admin":false},"created_at":"2016-01-12T01:33:44Z","updated_at":"2016-01-12T01:33:44Z","body":"@jdm: Alright, I think I figured this out. The confusion is that [section 7.4.1](https://tools.ietf.org/html/rfc6455#section-7.4.1) states that code 1005 is reserved to communicate that there was no code and should never actually be sent across the wire. So the right answer is to send *no* `code` in this case, expect no `code` to be echoed back, and set the `code` of the event to 1005 to communicate that this is what happened. The WPT websocket echo handler still needs to be updated to work that way, though – currently it sends back 1000 instead of nothing. Do you think I should send that change upstream first, or include it in a PR here first?"}}