Skip to content

Commit

Permalink
Send reason in the Websocket close handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
psdh committed Oct 5, 2015
1 parent 7debfd1 commit 61fa1e4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/script/dom/websocket.rs
Expand Up @@ -40,6 +40,7 @@ use websocket::client::receiver::Receiver;
use websocket::client::request::Url;
use websocket::client::sender::Sender;
use websocket::header::Origin;
use websocket::message::CloseData;
use websocket::result::WebSocketResult;
use websocket::stream::WebSocketStream;
use websocket::ws::receiver::Receiver as WSReceiver;
Expand Down Expand Up @@ -292,7 +293,9 @@ impl WebSocketMethods for WebSocket {
let mut sender = this.sender.borrow_mut();
//TODO: Also check if the buffer is full
if let Some(sender) = sender.as_mut() {
let _ = sender.lock().unwrap().send_message(Message::Close(None));
let code: u16 = this.code.get();
let reason = this.reason.borrow().clone();
let _ = sender.lock().unwrap().send_message(Message::Close(Some(CloseData::new(code, reason))));
}
}

Expand Down

0 comments on commit 61fa1e4

Please sign in to comment.