Did you know ... Search Documentation:
Pack lsp_server -- prolog/lsp_parser.pl
PublicShow source

Module for parsing the body & headers from an LSP client.

author
- James Cash
 lsp_request(-Req)// is det
A DCG nonterminal describing an HTTP request. Currently can only parse the request from a list of codes.

The HTTP headers are parsed into an assoc tree which maps strings to strings. The body of the request is parsed into a dict according to json_read_dict/3. The headers list must include a Content-Length header.

?- phrase(lsp_request(Req), `Content-Length: 7\r\n\r\n{"x":1}`).
Req = _{body:_{x:1}, headers:t("Content-Length", "7", -, t, t)}.
Arguments:
Req- a dict containing keys headers and body