mirror of
https://github.com/tiffany352/rink-rs
synced 2024-11-10 13:44:15 +00:00
parent
f3b7ad6d1b
commit
380bb11798
2 changed files with 9 additions and 2 deletions
|
@ -13,7 +13,7 @@ keywords = ["unit", "math", "conversion", "cli", "tool"]
|
|||
default = ["linefeed", "chrono-humanize", "gpl", "currency"]
|
||||
sandbox = ["libc", "ipc-channel"]
|
||||
gpl = []
|
||||
currency = ["hyper", "xml-rs", "json"]
|
||||
currency = ["hyper", "hyper-native-tls", "xml-rs", "json"]
|
||||
nightly = ["serde", "serde_derive"]
|
||||
|
||||
[dependencies]
|
||||
|
@ -24,6 +24,7 @@ chrono-tz = "0.2.2"
|
|||
chrono-humanize = { version = "0.0.6", optional = true }
|
||||
linefeed = { version = "0.1.4", optional = true }
|
||||
hyper = { version = "0.10.4", optional = true }
|
||||
hyper-native-tls = { version = "0.2.2", optional = true }
|
||||
libc = { version = "0.2.14", optional = true }
|
||||
ipc-channel = { version = "0.5.1", optional = true }
|
||||
xml-rs = { version = "0.3.4", optional = true }
|
||||
|
|
|
@ -45,6 +45,8 @@ extern crate ipc_channel;
|
|||
#[cfg(feature = "currency")]
|
||||
extern crate hyper;
|
||||
#[cfg(feature = "currency")]
|
||||
extern crate hyper_native_tls;
|
||||
#[cfg(feature = "currency")]
|
||||
extern crate xml;
|
||||
#[cfg(feature = "currency")]
|
||||
extern crate json;
|
||||
|
@ -370,6 +372,8 @@ fn cached(file: &str, url: &str, expiration: Duration) -> Result<File, String> {
|
|||
use std::io::{Read, Write};
|
||||
use hyper::Client;
|
||||
use hyper::status::StatusCode;
|
||||
use hyper::net::HttpsConnector;
|
||||
use hyper_native_tls::NativeTlsClient;
|
||||
|
||||
fn ts<T:Display>(x: T) -> String {
|
||||
format!("{}", x)
|
||||
|
@ -398,7 +402,9 @@ fn cached(file: &str, url: &str, expiration: Duration) -> Result<File, String> {
|
|||
try!(fs::create_dir_all(path.parent().unwrap()).map_err(|x| format!("{}", x)));
|
||||
let mut f = try!(File::create(tmppath.clone()).map_err(|x| format!("{}", x)));
|
||||
|
||||
let client = Client::new();
|
||||
let ssl = NativeTlsClient::new().unwrap();
|
||||
let connector = HttpsConnector::new(ssl);
|
||||
let client = Client::with_connector(connector);
|
||||
let mut res = try!(client.get(url).send().map_err(|x| format!("{}", x)));
|
||||
if res.status != StatusCode::Ok {
|
||||
return Err(format!("Request failed with status code {}", res.status))
|
||||
|
|
Loading…
Reference in a new issue