Skip to content

Fix accidental revert #516

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

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lsp/src/Language/LSP/Server/Control.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import qualified Colog.Core as L
import Colog.Core (LogAction (..), WithSeverity (..), Severity (..), (<&))
import Control.Concurrent
import Control.Concurrent.STM.TChan
import Control.Applicative((<|>))
import Control.Monad
import Control.Monad.STM
import Control.Monad.IO.Class
Expand Down Expand Up @@ -187,10 +188,23 @@ ioLoop ioLogger logger clientIn serverDefinition vfs sendMsg = do
go (parse parser remainder)

parser = do
try contentType <|> (return ())
len <- contentLength
try contentType <|> (return ())
_ <- string _ONE_CRLF
Attoparsec.take len

contentLength = do
_ <- string "Content-Length: "
len <- decimal
_ <- string _TWO_CRLF
Attoparsec.take len
_ <- string _ONE_CRLF
return len

contentType = do
_ <- string "Content-Type: "
skipWhile (/='\r')
_ <- string _ONE_CRLF
return ()

parseOne ::
MonadIO m
Expand Down Expand Up @@ -241,6 +255,8 @@ sendServer _logger msgChan clientOut = do
-- |
--
--
_ONE_CRLF :: BS.ByteString
_ONE_CRLF = "\r\n"
_TWO_CRLF :: BS.ByteString
_TWO_CRLF = "\r\n\r\n"

Expand Down