nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
a_star: don't crash on deserialization errors and limit static types
[nit.git]
/
lib
/
websocket
/
websocket.nit
diff --git
a/lib/websocket/websocket.nit
b/lib/websocket/websocket.nit
index
d384512
..
8a97421
100644
(file)
--- a/
lib/websocket/websocket.nit
+++ b/
lib/websocket/websocket.nit
@@
-22,8
+22,8
@@
import socket
import sha1
import base64
import sha1
import base64
-intrude import standard::stream
-intrude import standard::bytes
+intrude import core::stream
+intrude import core::bytes
# Websocket compatible listener
#
# Websocket compatible listener
#
@@
-66,7
+66,7
@@
class WebsocketConnection
super TCPStream
init do
super TCPStream
init do
- _buffer = new NativeString(1024)
+ _buffer = new CString(1024)
_buffer_pos = 0
_buffer_capacity = 1024
_buffer_length = 0
_buffer_pos = 0
_buffer_capacity = 1024
_buffer_length = 0
@@
-114,7
+114,7
@@
class WebsocketConnection
resp_map["Connection:"] = "Upgrade"
var key = heads["Sec-WebSocket-Key"]
key += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
resp_map["Connection:"] = "Upgrade"
var key = heads["Sec-WebSocket-Key"]
key += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
- key = key.sha1.encode_base64
+ key = key.sha1.encode_base64.to_s
resp_map["Sec-WebSocket-Accept:"] = key
var resp = resp_map.join("\r\n", " ")
resp += "\r\n\r\n"
resp_map["Sec-WebSocket-Accept:"] = key
var resp = resp_map.join("\r\n", " ")
resp += "\r\n\r\n"
@@
-137,10
+137,10
@@
class WebsocketConnection
ans_buffer.add(msg.length.to_b)
end
if msg isa FlatString then
ans_buffer.add(msg.length.to_b)
end
if msg isa FlatString then
- ans_buffer.append_ns_from(msg.items, msg.length, msg.index_from)
+ ans_buffer.append_ns_from(msg.items, msg.length, msg.first_byte)
else
for i in msg.substrings do
else
for i in msg.substrings do
- ans_buffer.append_ns_from(i.as(FlatString).items, i.length, i.as(FlatString).index_from)
+ ans_buffer.append_ns_from(i.as(FlatString).items, i.length, i.as(FlatString).first_byte)
end
end
return ans_buffer
end
end
return ans_buffer
@@
-236,9
+236,9
@@
class WebsocketConnection
end
# Unmasks a message sent by a client
end
# Unmasks a message sent by a client
- private fun unmask_message(key: NativeString, message: NativeString, len: Int): NativeString
+ private fun unmask_message(key: CString, message: CString, len: Int): CString
do
do
- var return_message = new NativeString(len)
+ var return_message = new CString(len)
for i in [0 .. len[ do
return_message[i] = message[i] ^ key[i % 4]
for i in [0 .. len[ do
return_message[i] = message[i] ^ key[i % 4]