diff --git a/Cargo.toml b/Cargo.toml index ff1942b..28e203c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "nano-get" description = """ A very tiny implementation of HTTP(s) GET, using minimal dependencies. """ -version = "0.2.2" +version = "0.2.3" authors = ["Rahul Thomas "] edition = "2018" license = "MIT" diff --git a/README.md b/README.md index 0e95d85..32d419c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A tiny implementation of HTTP GET using only the standard library by default. If you require `https`, please enable the `"https"` feature flag like: ``` -nano-get = { version = "0.2.2", features = ["https"] } +nano-get = { version = "0.2.3", features = ["https"] } ``` Enabling the `https` flag, uses the rust [openssl](https://crates.io/crates/openssl) crate. @@ -120,7 +120,7 @@ This is also not meant to be demonstrative of idiomatic uses of the async librar **Cargo.toml snippet** ```toml [dependencies] -nano-get = {version = "0.2.2", features = ["https"] } +nano-get = {version = "0.2.3", features = ["https"] } tokio = { version = "0.2.6", features = ["rt-threaded"] } futures = "0.3.1" ``` diff --git a/src/errors.rs b/src/errors.rs index e357ade..9431ea8 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -22,17 +22,8 @@ impl std::fmt::Display for NanoGetError { } } -//impl From for NanoGetError { -// fn from(err: std::io::Error) -> Self { -// -// } -//} - impl NanoGetError { pub fn new(kind: ErrorKind) -> Self { - NanoGetError {kind} + NanoGetError { kind } } -} - - -//pub type Result = std::result::Result; \ No newline at end of file +} \ No newline at end of file diff --git a/src/https.rs b/src/https.rs index 27064f9..76b0484 100644 --- a/src/https.rs +++ b/src/https.rs @@ -3,13 +3,11 @@ extern crate openssl; use std::net::TcpStream; -use openssl::ssl::{SslConnector, SslMethod}; +use openssl::ssl::{SslConnector, SslMethod, SslStream}; use super::{Request, Response, ToUrl, Url}; -use super::http; - -use openssl::ssl::SslStream; use super::errors::NanoGetError; +use super::http; /// The implementation of HTTPS GET using OpenSSL. /// diff --git a/src/lib.rs b/src/lib.rs index 582ab4c..f9589fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,7 +69,6 @@ //! ``` //! //! For details, check the `Request` and `Response` structure documentation. - pub use http::get_http; #[cfg(feature = "https")] pub use https::get_https; diff --git a/src/request.rs b/src/request.rs index e8c7fca..45ca497 100644 --- a/src/request.rs +++ b/src/request.rs @@ -1,13 +1,13 @@ use std::collections::HashMap; use std::error::Error; +use super::{ToUrl, Url}; use super::errors::NanoGetError; use super::http::request_http_get; +#[cfg(feature = "https")] use super::https::request_https_get; use super::Response; -use super::{ToUrl, Url}; - /// This is the basic HTTP Request Object. /// /// This is self-containing and you can execute the request using its execute method. diff --git a/src/response.rs b/src/response.rs index 1a83c56..3bbe724 100644 --- a/src/response.rs +++ b/src/response.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; -use std::fmt::{Display, Formatter, Error}; -use super::url::Tuple; +use std::fmt::{Display, Error, Formatter}; +use super::url::Tuple; /// This is the HTTP Reponse Object. /// @@ -81,7 +81,7 @@ fn process_head_lines(lines: Vec<&str>) -> (ResponseStatus, Option Option> { - return if lines.is_empty() { + if lines.is_empty() { None } else { let mut headers = HashMap::new(); diff --git a/src/url/mod.rs b/src/url/mod.rs index 50a7743..4df05cf 100644 --- a/src/url/mod.rs +++ b/src/url/mod.rs @@ -1,6 +1,6 @@ -pub mod models; +pub use self::models::{ToUrl, Tuple, Url}; -pub use self::models::{Url, ToUrl, Tuple}; +pub mod models; pub fn parse_proto(s: String, default_proto: Option) -> (String, String) { let parts: Vec<&str> = s.split("://").collect();