This commit is contained in:
Martin Algesten
2018-06-30 14:01:13 +02:00
parent ff582b8c6f
commit 0e4c326caf
3 changed files with 7 additions and 6 deletions

View File

@@ -7,8 +7,6 @@ use std::net::TcpStream;
use std::net::ToSocketAddrs;
use std::time::Duration;
#[cfg(feature = "tls")]
use native_tls::TlsConnector;
#[cfg(feature = "tls")]
use native_tls::TlsStream;
@@ -76,7 +74,8 @@ pub fn connect_http(unit: &Unit) -> Result<Stream, Error> {
#[cfg(feature = "tls")]
pub fn connect_https(unit: &Unit) -> Result<Stream, Error> {
//
use native_tls::TlsConnector;
let hostname = unit.url.host_str().unwrap();
let port = unit.url.port().unwrap_or(443);

View File

@@ -2,7 +2,7 @@ use agent::Unit;
use error::Error;
use header::Header;
use std::collections::HashMap;
use std::io::{Write, Cursor};
use std::io::{Cursor, Write};
use std::sync::{Arc, Mutex};
use stream::Stream;

View File

@@ -196,12 +196,14 @@ impl Unit {
fn match_cookies<'a>(jar: &'a CookieJar, domain: &str, path: &str, is_secure: bool) -> Vec<Header> {
jar.iter()
.filter(|c| {
// if there is a domain, it must be matched. if there is no domain, then ignore cookie
// if there is a domain, it must be matched.
// if there is no domain, then ignore cookie
let domain_ok = c
.domain()
.map(|cdom| domain.contains(cdom))
.unwrap_or(false);
// a path must match the beginning of request path. no cookie path, we say is ok. is it?!
// a path must match the beginning of request path.
// no cookie path, we say is ok. is it?!
let path_ok = c
.path()
.map(|cpath| path.find(cpath).map(|pos| pos == 0).unwrap_or(false))