Skip to content

Allow any order of headers in base protocol #9

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

Open
kristopher-h opened this issue Sep 18, 2018 · 2 comments
Open

Allow any order of headers in base protocol #9

kristopher-h opened this issue Sep 18, 2018 · 2 comments

Comments

@kristopher-h
Copy link

kristopher-h commented Sep 18, 2018

Hi,

Currently python-jsonrpc-server requires the Content-Length header to be sent first. I guess the following snippet is causing the issue:

        content_length = self._content_length(line)

        # Blindly consume all header lines
        while line and line.strip():
             line = self._rfile.readline()

I think it would be good to allow reading headers in any order. The LSP specification doesn't mention anything about order, even though it is listed in one, leaving it a bit open for interpretation.

Let me know if you would like a PR with a suggestion for a fix (assuming you agree with my conclusion that is).

Regards

@gatesn
Copy link
Contributor

gatesn commented Sep 18, 2018

Yup, completely agree. I went for the naive thing just to avoid taking a dependency on some lib with header parsing. Since there’s only one header we really care about though this should still be quite simple

@kristopher-h
Copy link
Author

I did PR to allow for parsing headers in any order here #11. I added some additional unit tests to cover some new scenarios as well. If I understood correctly, the intention was that the listen method should never raise. But instead just break on error (corrupt headers/messages)? Feel free to have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants