Struct aws_sdk_rust::http::client::proxy::Proxy [] [src]

pub struct Proxy {
    // some fields omitted
}

Configuration relating to an HTTP Proxy.

Examples

A proxy server with no credientials required:

extern crate habitat_http_client;
extern crate url;

use std::str::FromStr;
use url::Url;
use habitat_http_client::proxy::Proxy;

fn main() {
    let url = Url::from_str("http://proxy.example.com:8001/").unwrap();
    let proxy = Proxy::new(url, None).unwrap();

    assert_eq!(proxy.scheme(), "http");
    assert_eq!(proxy.host(), "proxy.example.com");
    assert_eq!(proxy.port(), 8001);
    assert!(proxy.authorization_header_value().is_none());
}

A proxy server using basic authorization:

extern crate habitat_http_client;
extern crate url;

use std::str::FromStr;
use url::Url;
use habitat_http_client::proxy::{ProxyBasicAuthorization, Proxy};

fn main() {
    let url = Url::from_str("http://proxy.example.com").unwrap();
    let authz = ProxyBasicAuthorization::new("foo".to_string(), "bar".to_string());
    let proxy = Proxy::new(url, Some(authz)).unwrap();

    assert_eq!(proxy.scheme(), "http");
    assert_eq!(proxy.host(), "proxy.example.com");
    assert_eq!(proxy.port(), 80);
    assert_eq!(proxy.authorization_header_value().unwrap(), "Basic Zm9vOmJhcg==");
}

Methods

impl Proxy
[src]

Create and return a new Proxy.

Errors

  • If the proxy scheme is invalid (i.e. not "http" or "https")
  • If the proxy Url has an empty host entry
  • If the proxy Url has an unknown port number

Returns the scheme for the proxy server.

Returns the host entry for the proxy server.

Returns the port number for the proxy server.

Returns an Option of a String representing the value of a Proxy-Authorization HTTP header.

Trait Implementations

impl PartialEq for Proxy
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Debug for Proxy
[src]

Formats the value using the given formatter.