Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add readline(keep_max) to optimize memory usage #1

Open
Neradoc opened this issue Feb 23, 2021 · 0 comments
Open

Add readline(keep_max) to optimize memory usage #1

Neradoc opened this issue Feb 23, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Neradoc
Copy link
Owner

Neradoc commented Feb 23, 2021

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)
@Neradoc Neradoc added the enhancement New feature or request label Feb 23, 2021
@Neradoc Neradoc self-assigned this Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant