Fetching content from HTTPS using rustls (#2024)

* Fetching https

* Fetching dispatcher (HTTP, HTTPS)

* Fetching from github

* Chunked encoding parser

* Abort support

* Fixing tests and review comments

* Cargo.lock order [ci skip]

* Relaxed -> SeqCst
This commit is contained in:
Tomasz Drwięga
2016-09-03 01:34:32 +02:00
committed by Arkadiy Paronyan
parent c0b097832b
commit 59f18ab958
20 changed files with 5730 additions and 42 deletions

View File

@@ -69,7 +69,7 @@ impl<T> Hashable for T where T: AsRef<[u8]> {
}
/// Calculate SHA3 of given stream.
pub fn sha3<R: io::Read>(r: &mut R) -> Result<H256, io::Error> {
pub fn sha3(r: &mut io::BufRead) -> Result<H256, io::Error> {
let mut output = [0u8; 32];
let mut input = [0u8; 1024];
let mut sha3 = Keccak::new_keccak256();
@@ -90,7 +90,7 @@ pub fn sha3<R: io::Read>(r: &mut R) -> Result<H256, io::Error> {
#[cfg(test)]
mod tests {
use std::fs;
use std::io::Write;
use std::io::{Write, BufReader};
use super::*;
#[test]
@@ -113,7 +113,7 @@ mod tests {
file.write_all(b"something").unwrap();
}
let mut file = fs::File::open(&path).unwrap();
let mut file = BufReader::new(fs::File::open(&path).unwrap());
// when
let hash = sha3(&mut file).unwrap();