Skip to content

Commit 9ab9a16

Browse files
committed
fix: allowing proxy from environment (#367)
1 parent 03e7ed3 commit 9ab9a16

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## [unreleased]
22
### Bug fixes
3+
- [#368](https://github.com/influxdata/influxdb-client-go/pull/368) Allowing proxy from environment variable
34

45
## 2.12.1 [2022-12-01]
56
### Bug fixes

api/http/options.go

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func (o *Options) HTTPClient() *http.Client {
4040
o.httpClient = &http.Client{
4141
Timeout: time.Second * time.Duration(o.HTTPRequestTimeout()),
4242
Transport: &http.Transport{
43+
Proxy: http.ProxyFromEnvironment,
4344
DialContext: (&net.Dialer{
4445
Timeout: 5 * time.Second,
4546
}).DialContext,

api/http/options_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package http_test
66

77
import (
88
"crypto/tls"
9+
"github.com/stretchr/testify/require"
910
nethttp "net/http"
1011
"testing"
1112
"time"
@@ -20,6 +21,9 @@ func TestDefaultOptions(t *testing.T) {
2021
assert.Equal(t, uint(20), opts.HTTPRequestTimeout())
2122
assert.NotNil(t, opts.HTTPClient())
2223
assert.True(t, opts.OwnHTTPClient())
24+
transport, ok := opts.HTTPClient().Transport.(*nethttp.Transport)
25+
require.True(t, ok)
26+
assert.NotNil(t, transport.Proxy)
2327
assert.EqualValues(t, "", opts.ApplicationName())
2428
}
2529

0 commit comments

Comments
 (0)