Skip to content

Commit b7dbf5d

Browse files
authored
Merge branch 'main' into main
2 parents a1dd45a + 1422cc5 commit b7dbf5d

5 files changed

Lines changed: 102 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# v2.45.0, 2026-04-13 <!-- Release notes generated using configuration in .github/release.yml at main -->
2+
3+
## What's Changed
4+
5+
### Bug Fixes :bug:
6+
* fix: set req.Host for Host header in HTTP transport by @binger-li-dd in https://github.com/ClickHouse/clickhouse-go/pull/1826
7+
8+
### Other Changes 🛠
9+
* chore: pass explicity github token for claude review by @kavirajk in https://github.com/ClickHouse/clickhouse-go/pull/1818
10+
11+
12+
## New Contributors
13+
* @binger-li-dd made their first contribution in https://github.com/ClickHouse/clickhouse-go/pull/1826
14+
15+
**Full Changelog**: https://github.com/ClickHouse/clickhouse-go/compare/v2.44.0...v2.45.0
16+
117
# v2.44.0, 2026-03-31 <!-- Release notes generated using configuration in .github/release.yml at main -->
218

319
## What's Changed

client_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ClientName = "clickhouse-go"
1313

1414
const (
1515
ClientVersionMajor = 2
16-
ClientVersionMinor = 44
16+
ClientVersionMinor = 45
1717
ClientVersionPatch = 0
1818
ClientTCPProtocolVersion = proto.DBMS_TCP_PROTOCOL_VERSION
1919
)

conn_http.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ func applyOptionsToRequest(ctx context.Context, req *http.Request, opt *Options)
137137
req.Header.Set("User-Agent", opt.ClientInfo.Append(queryOpt.clientInfo).String())
138138

139139
for k, v := range opt.HttpHeaders {
140-
req.Header.Set(k, v)
140+
if strings.EqualFold(k, "Host") {
141+
req.Host = v
142+
} else {
143+
req.Header.Set(k, v)
144+
}
141145
}
142146

143147
return nil

conn_http_test.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package clickhouse
22

33
import (
4+
"context"
45
"net/http"
56
"testing"
67
)
@@ -20,3 +21,81 @@ func TestCreateHTTPRoundTripper(t *testing.T) {
2021
t.Fatal("TransportFn not called")
2122
}
2223
}
24+
25+
func TestApplyOptionsToRequest_HostHeader(t *testing.T) {
26+
tests := []struct {
27+
name string
28+
headers map[string]string
29+
expectedHost string
30+
expectedInMap map[string]string
31+
unexpectedInMap []string
32+
}{
33+
{
34+
name: "Host header sets req.Host",
35+
headers: map[string]string{"Host": "my-service.example.com"},
36+
expectedHost: "my-service.example.com",
37+
unexpectedInMap: []string{"Host"},
38+
},
39+
{
40+
name: "lowercase host header sets req.Host",
41+
headers: map[string]string{"host": "my-service.example.com"},
42+
expectedHost: "my-service.example.com",
43+
unexpectedInMap: []string{"Host"},
44+
},
45+
{
46+
name: "uppercase HOST header sets req.Host",
47+
headers: map[string]string{"HOST": "my-service.example.com"},
48+
expectedHost: "my-service.example.com",
49+
unexpectedInMap: []string{"Host"},
50+
},
51+
{
52+
name: "Host header with other headers",
53+
headers: map[string]string{
54+
"Host": "my-service.example.com",
55+
"X-Custom-Token": "abc123",
56+
},
57+
expectedHost: "my-service.example.com",
58+
expectedInMap: map[string]string{"X-Custom-Token": "abc123"},
59+
unexpectedInMap: []string{"Host"},
60+
},
61+
{
62+
name: "no Host header leaves req.Host unchanged",
63+
headers: map[string]string{"X-Custom": "value"},
64+
expectedHost: "localhost:8123",
65+
expectedInMap: map[string]string{"X-Custom": "value"},
66+
},
67+
}
68+
69+
for _, tt := range tests {
70+
t.Run(tt.name, func(t *testing.T) {
71+
req, err := http.NewRequest(http.MethodPost, "http://localhost:8123/", nil)
72+
if err != nil {
73+
t.Fatalf("failed to create request: %s", err)
74+
}
75+
76+
opts := &Options{
77+
HttpHeaders: tt.headers,
78+
}
79+
80+
if err := applyOptionsToRequest(context.Background(), req, opts); err != nil {
81+
t.Fatalf("applyOptionsToRequest failed: %s", err)
82+
}
83+
84+
if req.Host != tt.expectedHost {
85+
t.Errorf("req.Host = %q, want %q", req.Host, tt.expectedHost)
86+
}
87+
88+
for k, v := range tt.expectedInMap {
89+
if got := req.Header.Get(k); got != v {
90+
t.Errorf("req.Header[%q] = %q, want %q", k, got, v)
91+
}
92+
}
93+
94+
for _, k := range tt.unexpectedInMap {
95+
if got := req.Header.Get(k); got != "" {
96+
t.Errorf("req.Header[%q] = %q, want it absent", k, got)
97+
}
98+
}
99+
})
100+
}
101+
}

contributors/list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ alex <alex@localhost.localdomain>
199199
anton troyanov <anton@troyanov.net>
200200
astduman <41344369+Astemirdum@users.noreply.github.com>
201201
barkhayot <barkhayotoff@gmail.com>
202+
binger-li-dd <binger.li@doordash.com>
202203
caleb.xiang <90543061+cxiang03@users.noreply.github.com>
203204
candiduslynx <candiduslynx@users.noreply.github.com>
204205
chengzhi <chengzhi@shinnytech.com>

0 commit comments

Comments
 (0)