swindon-rs / tk-http

Full featured HTTP and Websockets library for rust/tokio
Apache License 2.0
136 stars 10 forks source link

Integrating with tokio-tls #27

Closed codri closed 6 years ago

codri commented 7 years ago

Hi,

I've seen in the example for tls_client tokio-rustls is used, it would be great to have an example of using tokio-tls, which will use the native tls libs.

I'm still new to the tokio/futures libs, so not sure will be able to pull it off without reading the source for tokio/futures/tk-http/tokio-tls.

So, if you could please provide an example for it working or confirm that it should work, that would be great.

Thanks

tailhook commented 7 years ago

Yes, it should work. It has same connect_async interface, so the only thing that may need to be changed (except, obviously, extern crate and use statements) a way you prepare configuration for the connection.

Should be easy, maybe I'll find some time for the work in the next few days, but contributions are welcome.

codri commented 7 years ago

I think I got it to work(compile), but not sure, as I can't understand how to do a connection and request against one domain.

Why is the example a secure connection is established against google.com? https://github.com/swindon-rs/tk-http/blob/master/examples/tls_client.rs#L47

But the request is against rust-lang.org https://github.com/swindon-rs/tk-http/blob/master/examples/tls_client.rs#L51

Is this expected?

tailhook commented 7 years ago

I think I got it to work(compile), but not sure, as I can't understand how to do a connection and request against one domain.

Great! Do you mind making a pull request?

Why is the example a secure connection is established against google.com?

It's a mistake. You may fix it as part of PR adding tokio-tls example.

codri commented 7 years ago

Will do.

I've tested tokio-tls with rust-lang.org and it works. I'm able to download a rust-lang page through https. Will send a pull request, most likely tomorrow.

nayato commented 6 years ago

safe to close this issue I guess