Switch to Result-based API. (#132)
Gets rid of synthetic_error, and makes the various send_* methods return `Result<Response, Error>`. Introduces a new error type "HTTP", which represents an error due to status codes 4xx or 5xx. The HTTP error type contains a boxed Response, so users can read the actual response if they want. Adds an `error_for_status` setting to disable the functionality of treating 4xx and 5xx as errors. Adds .unwrap() to a lot of tests. Fixes #128.
This commit is contained in:
committed by
GitHub
parent
257d4e54dd
commit
e36c1c2aa1
@@ -1,3 +1,4 @@
|
||||
use log::debug;
|
||||
use std::fmt;
|
||||
use std::io::{self, BufRead, BufReader, Cursor, ErrorKind, Read, Write};
|
||||
use std::net::SocketAddr;
|
||||
@@ -416,6 +417,7 @@ pub(crate) fn connect_host(unit: &Unit, hostname: &str, port: u16) -> Result<Tcp
|
||||
None => None,
|
||||
};
|
||||
|
||||
debug!("connecting to {}", &sock_addr);
|
||||
// connect with a configured timeout.
|
||||
let stream = if Some(Proto::SOCKS5) == proto {
|
||||
connect_socks5(
|
||||
|
||||
Reference in New Issue
Block a user