Skip to content

Instantly share code, notes, and snippets.

@Lysxia

Lysxia/main.rs Secret

Created May 24, 2019 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lysxia/ed129e39e4cb730c9458408690187abf to your computer and use it in GitHub Desktop.
Save Lysxia/ed129e39e4cb730c9458408690187abf to your computer and use it in GitHub Desktop.
extern crate futures;
extern crate reqwest;
#[macro_use] extern crate log;
extern crate env_logger;
use std::fmt;
use log::{debug};
use reqwest::async as reqwest_async;
use futures::{Async, Future, Poll, Stream};
fn main() {
let mut l = tokio::runtime::Runtime::new().unwrap();
let c = reqwest_async::Client::new();
let uri = "https://nest.pijul.com/pijul_org/pijul/.pijul/patches/".to_string()
+ "8UhQnQGqctQvoavXPHF544iRf47dSMEPFCWx3vBEwq4Egav6vrzoPwqQm6cHBTbwCH4XWidGEYAvkD2xgzsNd7Pf"
+ ".gz";
let uri : reqwest::Url = uri.parse().unwrap();
env_logger::init();
for i in 0..600 {
debug!("{:?}", i);
let res = l.block_on(
c.get(uri.clone()).send()
.and_then(move |resp| {
debug!("{:?} / {:?} bytes", resp.status(), resp.content_length());
if resp.status() == reqwest::StatusCode::OK {
// let res : Vec<u8> = Vec::new();
futures::future::Either::A(
resp.into_body()
.fold((), |(), x| {
// res.extend(x.iter());
futures::future::ok::<_, reqwest::Error>(())
})
)
} else {
futures::future::Either::B(futures::future::ok(()))
}
})
// c.execute(reqwest::async::Request::new(reqwest::Method::GET, uri.clone()))
).unwrap();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment