[][src]Struct solicit::http::client::tls::TlsConnector

pub struct TlsConnector<'a, 'ctx> {
    pub host: &'a str,
    // some fields omitted
}

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.

Example

Issue a GET request over https using the TlsConnector

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());

Fields

host: &'a str

Implementations

impl<'a, 'ctx> TlsConnector<'a, 'ctx>[src]

pub fn new<P: AsRef<Path>>(
    host: &'a str,
    ca_file_path: &'ctx P
) -> TlsConnector<'a, 'ctx>
[src]

Creates a new TlsConnector that will create a new SslContext before trying to establish the TLS connection. The path to the CA file that the context will use needs to be provided.

pub fn with_context(
    host: &'a str,
    context: &'ctx SslContext
) -> TlsConnector<'a, 'ctx>
[src]

Creates a new TlsConnector that will use the provided context to create the SslStream that will back the HTTP/2 connection.

pub fn build_default_context(
    ca_file_path: &Path
) -> Result<SslContext, TlsConnectError>
[src]

Builds up a default SslContext instance wth TLS settings that the HTTP/2 spec mandates. The path to the CA file needs to be provided.

Trait Implementations

impl<'a, 'ctx> HttpConnect for TlsConnector<'a, 'ctx>[src]

type Stream = SslStream<TcpStream>

The type of the underlying transport stream that the HttpConnections produced by this HttpConnect implementation will be based on. Read more

type Err = TlsConnectError

The type of the error that can be produced by trying to establish the connection (i.e. calling the connect method). Read more

Auto Trait Implementations

impl<'a, 'ctx> RefUnwindSafe for TlsConnector<'a, 'ctx>

impl<'a, 'ctx> Send for TlsConnector<'a, 'ctx>

impl<'a, 'ctx> Sync for TlsConnector<'a, 'ctx>

impl<'a, 'ctx> Unpin for TlsConnector<'a, 'ctx>

impl<'a, 'ctx> UnwindSafe for TlsConnector<'a, 'ctx>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.