[−][src]Module solicit::http::client::tls
The module contains helpers for implementing TLS-based client connections.
Available only when the "tls"
crate feature is enabled.
Depends on the openssl
crate.
Example
Establishing a new client connection using the TlsConnector
and issuing a GET
request.
// Remember to enable the "tls" feature for `solicit` use solicit::http::client::tls::TlsConnector; use solicit::client::SimpleClient; use std::str; // Connect to an HTTP/2 aware server let path = "/path/to/certs.pem"; let connector = TlsConnector::new("http2bin.org", &path); let mut client = SimpleClient::with_connector(connector).unwrap(); let response = client.get(b"/get", &[]).unwrap(); assert_eq!(response.stream_id, 1); assert_eq!(response.status_code().unwrap(), 200); // Dump the headers and the response body to stdout. // They are returned as raw bytes for the user to do as they please. // (Note: in general directly decoding assuming a utf8 encoding might not // always work -- this is meant as a simple example that shows that the // response is well formed.) for header in response.headers.iter() { println!("{}: {}", str::from_utf8(header.name()).unwrap(), str::from_utf8(header.value()).unwrap()); } println!("{}", str::from_utf8(&response.body).unwrap());
Structs
TlsConnector | A struct implementing the functionality of establishing a TLS-backed TCP stream that can be used by an HTTP/2 connection. Takes care to set all the TLS options to those allowed by the HTTP/2 spec, as well as of the protocol negotiation. |
Enums
TlsConnectError | An enum representing possible errors that can arise when trying to establish an HTTP/2 connection over TLS. |