readline(keep_max) reads a full line, but only returns keep_max characters, avoiding unnecessary memory allocations.
readline(keep_max = 0) simply skips a line, as uwebsockets discards all headers but the first one.
Return the total number of characters in addition to the captured data, to differentiate between an empty line and keep_max = 0.
header,lenh = sock.readline(keep_max = 13)
assert header.startswith(b'HTTP/1.1 101 '), header
while lenh > 0:
if __debug__: LOGGER.debug(str(header))
header,lenh = sock.readline(keep_max = 0)
readline(keep_max)reads a full line, but only returns keep_max characters, avoiding unnecessary memory allocations.readline(keep_max = 0)simply skips a line, as uwebsockets discards all headers but the first one.Return the total number of characters in addition to the captured data, to differentiate between an empty line and keep_max = 0.