Skip to content

Commit

Permalink
Test for connect proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
algesten committed Jan 7, 2025
1 parent f4f2f4a commit ec7311d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ features = ["rustls", "platform-verifier", "native-tls", "socks-proxy", "cookies

[dependencies]
base64 = "0.22.1"
ureq-proto = "0.2.2"
ureq-proto = "0.2.3"
# ureq-proto = { path = "../ureq-proto" }
log = "0.4.22"
once_cell = "1.19.0"
Expand Down
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,22 @@ pub(crate) mod test {
let _ = agent.get("http://cookie.test/cookie-test").call().unwrap();
}

#[test]
#[cfg(feature = "_test")]
fn http_connect_proxy() {
init_test_log();

let proxy = Proxy::new("http://my_proxy:1234/connect-proxy").unwrap();

let agent = Agent::config_builder()
.proxy(Some(proxy))
.build()
.new_agent();

let mut res = agent.get("http://httpbin.org/get").call().unwrap();
res.body_mut().read_to_string().unwrap();
}

// This doesn't need to run, just compile.
fn _ensure_send_sync() {
fn is_send(_t: impl Send) {}
Expand Down
19 changes: 19 additions & 0 deletions src/unversioned/transport/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,25 @@ fn setup_default_handlers(handlers: &mut Vec<TestHandler>) {
handlers,
);

maybe_add(
TestHandler::new("/connect-proxy", |_uri, req, w| {
assert_eq!(req.uri(), "httpbin.org:80");
write!(
w,
"HTTP/1.1 200 OK\r\n\
\r\n\
HTTP/1.1 200 OK\r\n\
Content-Type: application/json\r\n\
Content-Length: {}\r\n\
\r\n",
HTTPBIN_GET.as_bytes().len()
)?;
w.write_all(HTTPBIN_GET.as_bytes())?;
Ok(())
}),
handlers,
);

#[cfg(feature = "charset")]
{
let (cow, _, _) =
Expand Down

0 comments on commit ec7311d

Please sign in to comment.