Skip to content

Commit

Permalink
fix: stop using hyper directly; use imageflow_helpers (and fix some w…
Browse files Browse the repository at this point in the history
…arnings)
  • Loading branch information
lilith committed Jan 25, 2017
1 parent a8f701e commit 35c21b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
18 changes: 6 additions & 12 deletions imageflow_core/tests/visuals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extern crate imageflow_core;
extern crate libc;
extern crate rustc_serialize;
extern crate imageflow_types as s;
extern crate imageflow_helpers as hlp;
extern crate serde;
extern crate serde_json;

Expand Down Expand Up @@ -360,7 +361,7 @@ fn test_get_info_png() {
0x00, 0x00, 0x0A, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01,
0x0D, 0x0A, 0x2D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82 ];

let info = imageflow_core::clients::stateless::LibClient {}.get_image_info(&tinypng).expect("Image response should be valid");
let _ = imageflow_core::clients::stateless::LibClient {}.get_image_info(&tinypng).expect("Image response should be valid");
}

//#[test]
Expand All @@ -369,7 +370,7 @@ fn test_get_info_png() {
// 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00,
// 0x00, 0x00, 0x0A, 0x49 ];
//
// let info = imageflow_core::clients::stateless::LibClient {}.get_image_info(&tinypng).err().expect("Should fail");
// let _ = imageflow_core::clients::stateless::LibClient {}.get_image_info(&tinypng).err().expect("Should fail");
//}


Expand Down Expand Up @@ -490,7 +491,6 @@ use std::collections::HashMap;
use ::std::fs::File;
use ::std::path::{PathBuf};
use ::std::io::Write;
use hyper::Client;


fn checksum_bitmap(bitmap: &BitmapBgra) -> String {
Expand Down Expand Up @@ -535,12 +535,13 @@ fn save_list(c: &ChecksumCtx, map: &HashMap<String,String>) -> Result<(),()>{
Ok(())
}


#[allow(unused_variables)]
fn load_checksum(c: &ChecksumCtx, name: &str) -> Option<String>{
#[allow(unused_variables)]
let lock = CHECKSUM_FILE.read().unwrap();
load_list(c).unwrap().get(name).and_then(|v|Some(v.to_owned()))
}
#[allow(unused_variables)]
fn save_checksum(c: &ChecksumCtx, name: String, checksum: String) -> Result<(),()>{
#[allow(unused_variables)]
let lock = CHECKSUM_FILE.write().unwrap();
Expand All @@ -551,14 +552,7 @@ fn save_checksum(c: &ChecksumCtx, name: String, checksum: String) -> Result<(),(
}

fn fetch_bytes(url: &str) -> Vec<u8> {
let client = Client::new();
let mut res = client.get(url).send().unwrap();
if res.status != hyper::Ok {
panic!("Did you forget to upload {} to s3?", url);
}
let mut source_bytes = Vec::new();
let _ = res.read_to_end(&mut source_bytes).unwrap();
source_bytes
hlp::fetching::fetch_bytes(url).expect("Did you forget to upload {} to s3?")
}

fn download(c: &ChecksumCtx, checksum: &str){
Expand Down
2 changes: 1 addition & 1 deletion imageflow_helpers/src/fetching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ::hyper::net::HttpsConnector;
use ::hyper_native_tls::NativeTlsClient;

#[cfg(not(any(target_os = "windows", target_os = "macos")))]
use openssl::ssl::{self, SslMethod, SslConnectorBuilder};
use openssl::ssl::{SslMethod, SslConnectorBuilder};
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
use hyper_openssl::OpensslClient;

Expand Down
4 changes: 2 additions & 2 deletions imageflow_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ fn static_setup(mount: &MountLocation) -> Result<(Static, EngineHandler<Static>)
let path = Path::new(&mount.engine_args[0]).canonicalize().map_err(|e| format!("{:?}", e))?;
let h = if mount.engine_args.len() > 1 {
let mins = mount.engine_args[1].parse::<i64>().expect("second argument to static must be the number of minutes to browser cache for");
Static::new(path) // .cache(Duration::minutes(mins))
Static::new(path) // .cache(Duration::minutes(mins)) (we must compile staticfile with the 'cache' feature enabled)
} else {
Static::new(path)
};
Expand All @@ -505,7 +505,7 @@ fn permacache_proxy_handler(req: &mut Request, base_url: &String, mount: &MountL
let remote_url = format!("{}{}{}", base_url, &url.path()[1..], req.url.query().unwrap_or(""));

match fetch_response_using_cache_by_url(&shared.source_cache, &remote_url) {
Ok((output, perf)) => {
Ok((output, _)) => {
let mime = output.content_type
.parse::<Mime>()
.unwrap_or(Mime::from_str("application/octet-stream").unwrap());
Expand Down

0 comments on commit 35c21b1

Please sign in to comment.