Skip to content

Commit 6ed8fe8

Browse files
authored
Merge pull request #516 from haskell/mpj/fix-revert
Fix accidental revert
2 parents c0eda34 + 6554435 commit 6ed8fe8

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lsp/src/Language/LSP/Server/Control.hs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import qualified Colog.Core as L
2020
import Colog.Core (LogAction (..), WithSeverity (..), Severity (..), (<&))
2121
import Control.Concurrent
2222
import Control.Concurrent.STM.TChan
23+
import Control.Applicative((<|>))
2324
import Control.Monad
2425
import Control.Monad.STM
2526
import Control.Monad.IO.Class
@@ -187,10 +188,23 @@ ioLoop ioLogger logger clientIn serverDefinition vfs sendMsg = do
187188
go (parse parser remainder)
188189

189190
parser = do
191+
try contentType <|> (return ())
192+
len <- contentLength
193+
try contentType <|> (return ())
194+
_ <- string _ONE_CRLF
195+
Attoparsec.take len
196+
197+
contentLength = do
190198
_ <- string "Content-Length: "
191199
len <- decimal
192-
_ <- string _TWO_CRLF
193-
Attoparsec.take len
200+
_ <- string _ONE_CRLF
201+
return len
202+
203+
contentType = do
204+
_ <- string "Content-Type: "
205+
skipWhile (/='\r')
206+
_ <- string _ONE_CRLF
207+
return ()
194208

195209
parseOne ::
196210
MonadIO m
@@ -241,6 +255,8 @@ sendServer _logger msgChan clientOut = do
241255
-- |
242256
--
243257
--
258+
_ONE_CRLF :: BS.ByteString
259+
_ONE_CRLF = "\r\n"
244260
_TWO_CRLF :: BS.ByteString
245261
_TWO_CRLF = "\r\n\r\n"
246262

0 commit comments

Comments
 (0)