fix(vpn/tunnel): fix panic when starting tunnel with headers (#16565)

`http.Header` is a map so it needs to be initialized ..
This commit is contained in:
Ethan
2025-02-14 14:11:51 +11:00
committed by GitHub
parent b23e3f9132
commit edd982e852
2 changed files with 4 additions and 1 deletions

View File

@ -230,7 +230,7 @@ func (t *Tunnel) start(req *StartRequest) error {
if apiToken == "" {
return xerrors.New("missing api token")
}
var header http.Header
header := make(http.Header)
for _, h := range req.GetHeaders() {
header.Add(h.GetName(), h.GetValue())
}

View File

@ -100,6 +100,9 @@ func TestTunnel_StartStop(t *testing.T) {
TunnelFileDescriptor: 2,
CoderUrl: "https://coder.example.com",
ApiToken: "fakeToken",
Headers: []*StartRequest_Header{
{Name: "X-Test-Header", Value: "test"},
},
},
},
})