libscoop 0.1.0-beta.7

Rust library implementation of Scoop
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#![allow(dead_code)]
use curl::easy::Easy;
use std::time::Duration;

pub fn get_content_length(url: &str, proxy: Option<&str>) -> Option<f64> {
    let mut easy = Easy::new();
    easy.get(true).unwrap();
    easy.url(url).unwrap();
    if let Some(proxy) = proxy {
        easy.proxy(proxy).unwrap();
    }
    easy.nobody(true).unwrap();
    easy.follow_location(true).unwrap();
    easy.connect_timeout(Duration::from_secs(30)).unwrap();
    println!("get_content_length of: {}", url);
    easy.perform().unwrap();
    easy.content_length_download().ok()
}