@@ -15,14 +15,14 @@ import (
15
15
)
16
16
17
17
const (
18
- // "Header Content-Length" is the HTTP header name of the length of the content part in bytes. This header is required.
18
+ // HeaderContentLength is the HTTP header name of the length of the content part in bytes. This header is required.
19
19
// This entity header indicates the size of the entity-body, in bytes, sent to the recipient.
20
20
//
21
21
// RFC 7230, section 3.3.2: Content-Length:
22
22
// https://tools.ietf.org/html/rfc7230#section-3.3.2
23
23
HeaderContentLength = "Content-Length"
24
24
25
- // " HeaderContentType" is the mime type of the content part. Defaults to "application/vscode-jsonrpc; charset=utf-8".
25
+ // HeaderContentType is the mime type of the content part. Defaults to "application/vscode-jsonrpc; charset=utf-8".
26
26
// This entity header is used to indicate the media type of the resource.
27
27
//
28
28
// RFC 7231, section 3.1.1.5: Content-Type:
@@ -65,13 +65,17 @@ type stream struct {
65
65
outMu sync.Mutex
66
66
}
67
67
68
+ // NewStream returns a Stream built on top of an io.Reader and io.Writer
69
+ // The messages are sent with HTTP content length and MIME type headers.
70
+ // This is the format used by LSP and others.
68
71
func NewStream (in io.Reader , out io.Writer ) Stream {
69
72
return & stream {
70
73
in : bufio .NewReader (in ),
71
74
out : out ,
72
75
}
73
76
}
74
77
78
+ // Read reads data from stream.
75
79
func (s * stream ) Read (ctx context.Context ) ([]byte , error ) {
76
80
select {
77
81
case <- ctx .Done ():
@@ -118,6 +122,7 @@ func (s *stream) Read(ctx context.Context) ([]byte, error) {
118
122
return data , nil
119
123
}
120
124
125
+ // Write writes data to stream.
121
126
func (s * stream ) Write (ctx context.Context , data []byte ) error {
122
127
select {
123
128
case <- ctx .Done ():
0 commit comments