Read LSP message headers at once (#7449)
The current LSP headers reader implementation assumes a specific order (i.e., `Content-Length` first, and then `Content-Type`). Unfortunately, this assumption is not always valid, as no specification enforces the rule. @caius and I encountered this issue while implementing the Terraform LSP, where `Content-Type` comes first, breaking the implementation in #6929. This PR introduces a `read_headers` function, which asynchronously reads the incoming pipe until the headers' delimiter (i.e., '\r\n\r\n'), adding it to the message buffer, and returning an error when delimiter's not found. I added a few tests but only considered scenarios where headers are delivered at once (which should be the case?). I'm unsure if this suffices or if I should consider more scenarios; I would love to hear others' opinions. Release Notes: - N/A --------- Co-authored-by: Caius <caius@caius.name>
F
Federico Dionisi committed
2651037472709b54867793cea157a2645af34e7c
Parent: 93ceb89
Committed by GitHub <noreply@github.com>
on 2/9/2024, 5:40:50 PM