diff --git a/Cargo.toml b/Cargo.toml index a6a24adf4..983759218 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ ssl = ["openssl"] [dependencies] ascii = "0.8" chunked_transfer = "0.3" -encoding = "0.2" openssl = { version = "0.10", optional = true } url = "1.7" chrono = "0.4" diff --git a/src/lib.rs b/src/lib.rs index a768c80b6..fb91ba3f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -112,7 +112,6 @@ extern crate log; extern crate ascii; extern crate chunked_transfer; -extern crate encoding; extern crate url; extern crate chrono; @@ -141,8 +140,6 @@ mod client; mod common; mod request; mod response; - -#[allow(dead_code)] // TODO: remove when everything is implemented mod util; /// The main class of this library. diff --git a/src/util/encoding_decoder.rs b/src/util/encoding_decoder.rs deleted file mode 100644 index 1adbae3b1..000000000 --- a/src/util/encoding_decoder.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2015 The tiny-http Contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::io::Result as IoResult; -use std::io::{Cursor, Read}; -use encoding::{DecoderTrap, Encoding}; - -// TODO: for the moment the first call to read() reads the whole -// underlying reader at once and decodes it - -pub struct EncodingDecoder { - reader: R, - encoding: &'static Encoding, - content: Option>>, -} - -impl EncodingDecoder where R: Read { - pub fn new(reader: R, encoding: &'static Encoding) -> EncodingDecoder { - EncodingDecoder { - reader: reader, - encoding: encoding, - content: None, - } - } -} - -impl Read for EncodingDecoder where R: Read { - fn read(&mut self, buf: &mut [u8]) -> IoResult { - if self.content.is_none() { - let mut data = Vec::with_capacity(0); - try!(self.reader.read_to_end(&mut data)); - - let result = match self.encoding.decode(&data, DecoderTrap::Strict) { - Ok(s) => s, - Err(_) => panic!(), // FIXME: return Err(old_io::standard_error(old_io::InvalidInput)) - }; - - self.content = Some(Cursor::new(result.into_bytes())); - } - - if let Some(ref mut content) = self.content { - content.read(buf) - - } else { - unreachable!(); - } - } -} diff --git a/src/util/mod.rs b/src/util/mod.rs index e80f920db..0e6e71f50 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -13,7 +13,6 @@ // limitations under the License. pub use self::custom_stream::CustomStream; -pub use self::encoding_decoder::EncodingDecoder; pub use self::equal_reader::EqualReader; pub use self::messages_queue::MessagesQueue; pub use self::refined_tcp_stream::RefinedTcpStream; @@ -24,7 +23,6 @@ pub use self::task_pool::TaskPool; use std::str::FromStr; mod custom_stream; -mod encoding_decoder; mod equal_reader; mod messages_queue; mod refined_tcp_stream;