Skip to content

Commit 69d3aeb

Browse files
committed
ICE
1 parent 1993562 commit 69d3aeb

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

src/client/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ use std::iter::Extend;
2525
use url::UrlParser;
2626
use url::ParseError as UrlError;
2727

28+
29+
use openssl::ssl::SslContext;
30+
2831
use header::{Headers, Header, HeaderFormat};
2932
use header::common::{ContentLength, Location};
3033
use method::Method;
31-
use net::{NetworkConnector, HttpConnector, ContextVerifier};
34+
use net::{NetworkConnector, HttpConnector};
3235
use status::StatusClass::Redirection;
3336
use {Url, Port, HttpResult};
3437
use HttpError::HttpUriError;
@@ -47,15 +50,15 @@ pub struct Client<C> {
4750
redirect_policy: RedirectPolicy,
4851
}
4952

50-
impl Client<HttpConnector> {
53+
impl<V: FnMut(&mut SslContext) -> ()> Client<HttpConnector<V>> {
5154

5255
/// Create a new Client.
53-
pub fn new() -> Client<HttpConnector> {
56+
pub fn new() -> Client<HttpConnector<V>> {
5457
Client::with_connector(HttpConnector(None))
5558
}
5659

5760
/// Set the SSL verifier callback for use with OpenSSL.
58-
pub fn set_ssl_verifier(&mut self, verifier: ContextVerifier) {
61+
pub fn set_ssl_verifier(&mut self, verifier: V) {
5962
self.connector = HttpConnector(Some(verifier));
6063
}
6164

src/client/request.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use url::Url;
66
use method::{self, Method};
77
use header::Headers;
88
use header::common::{self, Host};
9-
use net::{NetworkStream, NetworkConnector, HttpConnector, Fresh, Streaming};
9+
use net::{NetworkStream, NetworkConnector, HttpConnector, Fresh, Streaming, NoSslVerify};
1010
use http::{HttpWriter, LINE_ENDING};
1111
use http::HttpWriter::{ThroughWriter, ChunkedWriter, SizedWriter, EmptyWriter};
1212
use version;
@@ -40,7 +40,7 @@ impl<W> Request<W> {
4040
impl Request<Fresh> {
4141
/// Create a new client request.
4242
pub fn new(method: method::Method, url: Url) -> HttpResult<Request<Fresh>> {
43-
let mut conn = HttpConnector(None);
43+
let mut conn = HttpConnector::<NoSslVerify>(None);
4444
Request::with_connector(method, url, &mut conn)
4545
}
4646

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(slicing_syntax, box_syntax)]
1+
#![feature(slicing_syntax, box_syntax, unboxed_closures)]
22
#![deny(missing_docs)]
33
#![allow(unstable)]
44
#![cfg_attr(test, deny(warnings))]

src/net.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,17 @@ impl NetworkStream for HttpStream {
309309

310310
/// A connector that will produce HttpStreams.
311311
#[allow(missing_copy_implementations)]
312-
pub struct HttpConnector(pub Option<ContextVerifier>);
312+
pub struct HttpConnector<T = NoSslVerify>(Option<T>);
313313

314-
/// A method that can set verification methods on an SSL context
315-
pub type ContextVerifier = for <'a> fn(&'a mut SslContext) -> ();
314+
/// A no-op verify callback
315+
pub struct NoSslVerify;
316316

317-
impl NetworkConnector for HttpConnector {
317+
impl Fn(&mut SslContext) -> () for NoSslVerify {
318+
#[inline(always)]
319+
fn call(&self, _: (&mut SslContext)) {}
320+
}
321+
322+
impl<T> NetworkConnector for HttpConnector<T> where T: FnMut(&mut SslContext) -> () {
318323
type Stream = HttpStream;
319324

320325
fn connect(&mut self, host: &str, port: Port, scheme: &str) -> IoResult<HttpStream> {

0 commit comments

Comments
 (0)