Skip to content

Commit

Permalink
fix: allowing proxy from environment (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlastahajek committed Dec 13, 2022
1 parent 03e7ed3 commit 9ab9a16
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [unreleased]
### Bug fixes
- [#368](https://github.com/influxdata/influxdb-client-go/pull/368) Allowing proxy from environment variable

## 2.12.1 [2022-12-01]
### Bug fixes
Expand Down
1 change: 1 addition & 0 deletions api/http/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (o *Options) HTTPClient() *http.Client {
o.httpClient = &http.Client{
Timeout: time.Second * time.Duration(o.HTTPRequestTimeout()),
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 5 * time.Second,
}).DialContext,
Expand Down
4 changes: 4 additions & 0 deletions api/http/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package http_test

import (
"crypto/tls"
"github.com/stretchr/testify/require"
nethttp "net/http"
"testing"
"time"
Expand All @@ -20,6 +21,9 @@ func TestDefaultOptions(t *testing.T) {
assert.Equal(t, uint(20), opts.HTTPRequestTimeout())
assert.NotNil(t, opts.HTTPClient())
assert.True(t, opts.OwnHTTPClient())
transport, ok := opts.HTTPClient().Transport.(*nethttp.Transport)
require.True(t, ok)
assert.NotNil(t, transport.Proxy)
assert.EqualValues(t, "", opts.ApplicationName())
}

Expand Down

0 comments on commit 9ab9a16

Please sign in to comment.