Comparison

net/websocket.lua @ 10112:b327f2870382

net.*: Remove tostring call from logging Taken care of by loggingmanager now
author Kim Alvefur <zash@zash.se>
date Tue, 30 Jul 2019 02:35:17 +0200
parent 8893:eb710675f7f8
child 10113:66a9bc2d5c8d
comparison
equal deleted inserted replaced
10111:0f335815244f 10112:b327f2870382
129 s.conn:close(); 129 s.conn:close();
130 end 130 end
131 function websocket_methods:close(code, reason) 131 function websocket_methods:close(code, reason)
132 if self.readyState < 2 then 132 if self.readyState < 2 then
133 code = code or 1000; 133 code = code or 1000;
134 log("debug", "closing WebSocket with code %i: %s" , code , tostring(reason)); 134 log("debug", "closing WebSocket with code %i: %s" , code , reason);
135 self.readyState = 2; 135 self.readyState = 2;
136 local conn = self.conn; 136 local conn = self.conn;
137 conn:write(frames.build_close(code, reason, true)); 137 conn:write(frames.build_close(code, reason, true));
138 -- Do not close socket straight away, wait for acknowledgement from server. 138 -- Do not close socket straight away, wait for acknowledgement from server.
139 self.close_timer = timer.add_task(close_timeout, close_timeout_cb, self); 139 self.close_timer = timer.add_task(close_timeout, close_timeout_cb, self);
243 or r.headers["upgrade"] ~= "websocket" 243 or r.headers["upgrade"] ~= "websocket"
244 or r.headers["sec-websocket-accept"] ~= base64.encode(sha1(key .. "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")) 244 or r.headers["sec-websocket-accept"] ~= base64.encode(sha1(key .. "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))
245 or (protocol and not protocol[r.headers["sec-websocket-protocol"]]) 245 or (protocol and not protocol[r.headers["sec-websocket-protocol"]])
246 then 246 then
247 s.readyState = 3; 247 s.readyState = 3;
248 log("warn", "WebSocket connection to %s failed: %s", url, tostring(b)); 248 log("warn", "WebSocket connection to %s failed: %s", url, b);
249 if s.onerror then s:onerror("connecting-failed"); end 249 if s.onerror then s:onerror("connecting-failed"); end
250 return; 250 return;
251 end 251 end
252 252
253 s.protocol = r.headers["sec-websocket-protocol"]; 253 s.protocol = r.headers["sec-websocket-protocol"];