Skip to content

Commit 7915847

Browse files
authored
Merge branch 'master' into enhance/uuid-types
2 parents 097c7f3 + ab2b09f commit 7915847

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
@@ -186,10 +187,23 @@ ioLoop ioLogger logger clientIn serverDefinition vfs sendMsg = do
186187
go (parse parser remainder)
187188

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

194208
parseOne ::
195209
MonadIO m
@@ -236,6 +250,8 @@ sendServer logger msgChan clientOut = do
236250
-- |
237251
--
238252
--
253+
_ONE_CRLF :: BS.ByteString
254+
_ONE_CRLF = "\r\n"
239255
_TWO_CRLF :: BS.ByteString
240256
_TWO_CRLF = "\r\n\r\n"
241257

0 commit comments

Comments
 (0)