You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// detect compression from http Content-Encoding header - note user will need to have set enable_http_compression
55
-
// for CH to respond with compressed data - we don't set this automatically as they might not have permissions
56
-
varbody []byte
57
-
//adding Accept-Encoding:gzip on your request means response won’t be automatically decompressed per https://github.com/golang/go/blob/master/src/net/http/transport.go#L182-L190
58
-
59
-
rw:=h.compressionPool.Get()
60
-
body, err=rw.read(res)
61
-
bufferSize:=h.blockBufferSize
62
-
ifoptions.blockBufferSize>0 {
63
-
// allow block buffer sze to be overridden per query
64
-
bufferSize=options.blockBufferSize
65
-
}
66
-
var (
67
-
errCh=make(chanerror)
68
-
stream=make(chan*proto.Block, bufferSize)
69
-
)
70
53
71
-
iflen(body) ==0 {
72
-
// queries with no results can get an empty body
73
-
gofunc() {
74
-
close(stream)
75
-
close(errCh)
76
-
}()
54
+
ifres.ContentLength==0 {
55
+
block:=&proto.Block{}
77
56
return&rows{
78
-
err: nil,
79
-
stream: stream,
80
-
errors: errCh,
81
-
block: &proto.Block{},
82
-
columns: []string{},
57
+
block: block,
58
+
columns: block.ColumnsNames(),
83
59
structMap: &structMap{},
84
60
}, nil
85
61
}
62
+
63
+
rw:=h.compressionPool.Get()
64
+
// The HTTPReaderWriter.NewReader will create a reader that will decompress it if needed,
65
+
// cause adding Accept-Encoding:gzip on your request means response won’t be automatically decompressed
66
+
// per https://github.com/golang/go/blob/master/src/net/http/transport.go#L182-L190.
67
+
// Note user will need to have set enable_http_compression for CH to respond with compressed data. we don't set this
68
+
// automatically as they might not have permissions.
69
+
reader, err:=rw.NewReader(res)
86
70
iferr!=nil {
71
+
res.Body.Close()
72
+
h.compressionPool.Put(rw)
87
73
returnnil, err
88
74
}
89
-
h.compressionPool.Put(rw)
90
-
reader:=chproto.NewReader(bytes.NewReader(body))
91
-
block, err:=h.readData(ctx, reader)
92
-
iferr!=nil {
75
+
chReader:=chproto.NewReader(reader)
76
+
block, err:=h.readData(ctx, chReader)
77
+
iferr!=nil&&!errors.Is(err, io.EOF) {
78
+
res.Body.Close()
79
+
h.compressionPool.Put(rw)
93
80
returnnil, err
94
81
}
95
82
83
+
bufferSize:=h.blockBufferSize
84
+
ifoptions.blockBufferSize>0 {
85
+
// allow block buffer sze to be overridden per query
0 commit comments