package linol

  1. Overview
  2. Docs
LSP server library

Install

dune-project
 Dependency

Authors

Maintainers

Sources

linol-0.12.tbz
sha256=c748f3c03525c1f438ccba7b71d31e91ae7bf4f857fade61005cc4533e3b7fc5
sha512=bc29a1ccf8bfbe7ba39f167397f2d45729e948bfc2db628ba24a1e5239ec64cda7c8356c3824e3c66a3630ca2addb58b444829707f155c2b58aef26c0ddfcabb

doc/src/linol.lsp/header.ml.html

Source file header.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
type t =
  { content_length : int
  ; content_type : string
  }

let content_type t = t.content_type
let content_length t = t.content_length

module Private = struct
  module Key = struct
    let content_length = "Content-Length"
    let content_type = "Content-Type"
  end
end

open Private

let crlf = "\r\n"

let to_string { content_length; content_type } =
  let b = Buffer.create 64 in
  let add = Buffer.add_string b in
  let line k v =
    add k;
    add ": ";
    add v;
    add crlf
  in
  line Key.content_length (string_of_int content_length);
  line Key.content_type content_type;
  add crlf;
  Buffer.contents b
;;

let default_content_type = "application/vscode-jsonrpc; charset=utf-8"

let create ?(content_type = default_content_type) ~content_length () =
  { content_length; content_type }
;;