rust-lang / rust-lang/rust-analyzer

Content-Length parsing too strict?

Open
#15,197 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lsp C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Hi,

I'm using a fork of Emacs that handles jsonrpc processing on a separate thread, and that version currently emits more than one space character between the 'Content-Length:' header and the actual field value. While I can easily change that fork to emit just a single space, I believe the standard allows for any amount of whitespace (RFC 2616, 4.2?). Also, I think the header names are supposed to be case-insensitive which as far as I can see isn't how the lsp-server crate handles the Content-Length header.

Looks to me like (if I'm interpreting the standard correctly) both would be fixed easily by adding one trim() and one to_lowercase() within lsp-server/src/msg.rs (read_msg_text)?
thanks,
Sebastian

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lsp-server/src/msg.rs at read_msg_text and review how the Content-Length header is parsed. Verify the stated whitespace and header-name case behavior against the referenced RFC, then confirm the parser accepts valid variations without changing other message handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.