package lsp

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

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 }
OCaml

Innovation. Community. Security.