Skip to content

Commit 84e5318

Browse files
committed
[bitreq] Rename Proxy::new to Proxy::new_http
In the future we'd like to support SOCKS proxies as well, so get ahead of it by renaming `Proxy::new` to `Proxy::new_http` to allow us to have a `Proxy::new_socks5` in a point release.
1 parent 701b9dc commit 84e5318

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bitreq/src/proxy.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Proxy {
4141
}
4242
}
4343

44-
/// Creates a new Proxy configuration.
44+
/// Creates a new Proxy configuration for an HTTP proxy supporting the `CONNECT` command.
4545
///
4646
/// Supported proxy format is:
4747
///
@@ -54,11 +54,11 @@ impl Proxy {
5454
/// # Example
5555
///
5656
/// ```
57-
/// let proxy = bitreq::Proxy::new("user:password@localhost:1080").unwrap();
57+
/// let proxy = bitreq::Proxy::new_http("user:password@localhost:1080").unwrap();
5858
/// let request = bitreq::post("http://example.com").with_proxy(proxy);
5959
/// ```
6060
///
61-
pub fn new<S: AsRef<str>>(proxy: S) -> Result<Self, Error> {
61+
pub fn new_http<S: AsRef<str>>(proxy: S) -> Result<Self, Error> {
6262
let proxy = proxy.as_ref();
6363
let authority = if let Some((proto, auth)) = split_once(proxy, "://") {
6464
if proto != "http" {
@@ -141,7 +141,7 @@ mod tests {
141141

142142
#[test]
143143
fn parse_proxy() {
144-
let proxy = Proxy::new("user:p@ssw0rd@localhost:9999").unwrap();
144+
let proxy = Proxy::new_http("user:p@ssw0rd@localhost:9999").unwrap();
145145
assert_eq!(proxy.user, Some(String::from("user")));
146146
assert_eq!(proxy.password, Some(String::from("p@ssw0rd")));
147147
assert_eq!(proxy.server, String::from("localhost"));
@@ -150,7 +150,7 @@ mod tests {
150150

151151
#[test]
152152
fn parse_regular_proxy_with_protocol() {
153-
let proxy = Proxy::new("http://localhost:1080").unwrap();
153+
let proxy = Proxy::new_http("http://localhost:1080").unwrap();
154154
assert_eq!(proxy.user, None);
155155
assert_eq!(proxy.password, None);
156156
assert_eq!(proxy.server, String::from("localhost"));

0 commit comments

Comments
 (0)