core :: Reader :: raw_read_bytes
max
bytes from the underlying stream into buf
,without considering any eventual buffer
Returns how many bytes were read
# Read at most `max` bytes from the underlying stream into `buf`,
# without considering any eventual buffer
#
# Returns how many bytes were read
protected fun raw_read_bytes(buf: CString, max: Int): Int do
var rd = 0
for i in [0 .. max[ do
var b = raw_read_byte
if b < 0 then break
buf[i] = b
rd += 1
end
return rd
end
lib/core/stream.nit:116,2--129,4
redef fun raw_read_bytes(ns, len) do
return origin.read_bytes_to_cstring(ns, len)
end
lib/core/protocol.nit:35,2--37,4
redef fun raw_read_bytes(ns, len) do
while not closed and frame_cursor >= frame_length do
read_frame_info
end
if closed then return -1
var available = frame_length - frame_cursor
var to_rd = len.min(available)
var rd = origin.read_bytes_to_cstring(ns, to_rd)
if rd < 0 then
close
return 0
end
if has_mask then
ns.xor(mask, rd, 4, mask_offset)
mask_offset = rd % 4
end
frame_cursor += rd
return rd
end
lib/websocket/websocket.nit:259,2--277,4