File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed
lsp/src/Language/LSP/Server Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import qualified Colog.Core as L
20
20
import Colog.Core (LogAction (.. ), WithSeverity (.. ), Severity (.. ), (<&) )
21
21
import Control.Concurrent
22
22
import Control.Concurrent.STM.TChan
23
+ import Control.Applicative ((<|>) )
23
24
import Control.Monad
24
25
import Control.Monad.STM
25
26
import Control.Monad.IO.Class
@@ -186,11 +187,34 @@ ioLoop ioLogger logger clientIn serverDefinition vfs sendMsg = do
186
187
go (parse parser remainder)
187
188
188
189
parser = do
189
- _ <- string " Content-Length: "
190
- len <- decimal
191
- _ <- string _TWO_CRLF
190
+ _ <- string " Content-"
191
+ len <- lengthFirst <|> typeFirst
192
192
Attoparsec. take len
193
193
194
+ lengthFirst = do
195
+ len <- headLength
196
+ _ <- string _ONE_CRLF
197
+ <|> (headType >> string _ONE_CRLF)
198
+ return len
199
+
200
+ typeFirst = do
201
+ _ <- headType
202
+ _ <- string " Content-"
203
+ len <- headLength
204
+ _ <- string _ONE_CRLF
205
+ return len
206
+
207
+ headLength = do
208
+ _ <- string " Length: "
209
+ len <- decimal
210
+ _ <- string _ONE_CRLF
211
+ return len
212
+
213
+ headType = do
214
+ skipWhile (/= ' \r ' )
215
+ _ <- string _ONE_CRLF
216
+ return ()
217
+
194
218
parseOne ::
195
219
MonadIO m
196
220
=> LogAction m (WithSeverity LspServerLog )
@@ -236,6 +260,8 @@ sendServer logger msgChan clientOut = do
236
260
-- |
237
261
--
238
262
--
263
+ _ONE_CRLF :: BS. ByteString
264
+ _ONE_CRLF = " \r\n "
239
265
_TWO_CRLF :: BS. ByteString
240
266
_TWO_CRLF = " \r\n\r\n "
241
267
You can’t perform that action at this time.
0 commit comments