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

Update documentation to reflect that you can use this as HTTP client #52

Open
anxiousmodernman opened this issue Feb 4, 2016 · 1 comment

Comments

@anxiousmodernman
Copy link

Based on the code comment here: https://github.com/spacemonkeygo/openssl/blob/master/http.go#L51

... it seems that an HTTP client is not implemented. Are there any known/recommended HTTP clients that can accept/embed the connection object created by this library? I do not need all of the functionality of the standard lib, just need to make REST calls against a secure service.

@jtolio
Copy link
Member

jtolio commented Feb 4, 2016

Yeah, so, that's a relatively stale comment back from Go 1.2, thanks for the reminder. I'm going to leave this issue open until I can actually fix the documentation, but just so you know, you should be able to set the DialTLS method in current Go stdlib http.Transport objects.

Something like this (haven't checked for validity) should work, assuming you already have created an *openssl.Ctx object.

   client = &http.Client{Transport: &http.Transport{
      DialTLS: func(network, address string) (net.Conn, error) {
        return openssl.Dial(network, address, ctx, 0)
      }}}

One downside to this approach is that you end up not using all of the settings you get on the DefaultTransport such as timeouts, so you'll have to reset timeouts again on this http.Client yourself (see how net/http's DefaultTransport is initialized)

@zeebo zeebo changed the title Question about alternative HTTP clients Update documentation to reflect that you can use this as HTTP client Mar 3, 2017
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

No branches or pull requests

2 participants