Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close #60 - go vet warning #61

Merged
merged 3 commits into from
Dec 13, 2017
Merged

Close #60 - go vet warning #61

merged 3 commits into from
Dec 13, 2017

Conversation

adriantam
Copy link
Contributor

Do not copy across http transport object as the internal implementation of DefaultTransport contains mutex.

Instead, initialise the return transport with the identical DefautlTransport value.

Do not copy across http transport object
Update to use real default client instead
@fiorix fiorix merged commit e0dbfba into fiorix:master Dec 13, 2017
@fiorix
Copy link
Owner

fiorix commented Dec 13, 2017

Squashed those commits during merge

@@ -95,8 +95,8 @@ func open(name string, cli *http.Client) (io.ReadCloser, error) {

// httpClient returns http client with default options
func httpClient(insecure bool) *http.Client {
transport := *(http.DefaultTransport.(*http.Transport))
client := &http.Client{}
transport := client.Transport.(*http.Transport)
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: insecure}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. I think this will not work. transport in client is nil by default. It will be initialized with http.DefaultTransport only on first request.
Here is an output: panic: interface conversion: http.RoundTripper is nil, not *http.Transport.
May be this variant https://stackoverflow.com/a/46011355/519917 may be used, but i not sure all Go versions would work with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we want to have InsecureSkipVerify? If not, maybe we can just have return &http.Client{}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is to go through invalid certificates. There are many of them around in proprietary systems.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^ that. We have to support InsecureSkipVerify, @adriantam.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old line does the right job. You'd have to set client.Transport = transport then.

@fiorix
Copy link
Owner

fiorix commented Dec 16, 2017

Fixed in e1518c1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants