Skip to content

Commit ec7311d

Browse files
committed
Test for connect proxy
1 parent f4f2f4a commit ec7311d

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ features = ["rustls", "platform-verifier", "native-tls", "socks-proxy", "cookies
5656

5757
[dependencies]
5858
base64 = "0.22.1"
59-
ureq-proto = "0.2.2"
59+
ureq-proto = "0.2.3"
6060
# ureq-proto = { path = "../ureq-proto" }
6161
log = "0.4.22"
6262
once_cell = "1.19.0"

src/lib.rs

+16
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,22 @@ pub(crate) mod test {
913913
let _ = agent.get("http://cookie.test/cookie-test").call().unwrap();
914914
}
915915

916+
#[test]
917+
#[cfg(feature = "_test")]
918+
fn http_connect_proxy() {
919+
init_test_log();
920+
921+
let proxy = Proxy::new("http://my_proxy:1234/connect-proxy").unwrap();
922+
923+
let agent = Agent::config_builder()
924+
.proxy(Some(proxy))
925+
.build()
926+
.new_agent();
927+
928+
let mut res = agent.get("http://httpbin.org/get").call().unwrap();
929+
res.body_mut().read_to_string().unwrap();
930+
}
931+
916932
// This doesn't need to run, just compile.
917933
fn _ensure_send_sync() {
918934
fn is_send(_t: impl Send) {}

src/unversioned/transport/test.rs

+19
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,25 @@ fn setup_default_handlers(handlers: &mut Vec<TestHandler>) {
338338
handlers,
339339
);
340340

341+
maybe_add(
342+
TestHandler::new("/connect-proxy", |_uri, req, w| {
343+
assert_eq!(req.uri(), "httpbin.org:80");
344+
write!(
345+
w,
346+
"HTTP/1.1 200 OK\r\n\
347+
\r\n\
348+
HTTP/1.1 200 OK\r\n\
349+
Content-Type: application/json\r\n\
350+
Content-Length: {}\r\n\
351+
\r\n",
352+
HTTPBIN_GET.as_bytes().len()
353+
)?;
354+
w.write_all(HTTPBIN_GET.as_bytes())?;
355+
Ok(())
356+
}),
357+
handlers,
358+
);
359+
341360
#[cfg(feature = "charset")]
342361
{
343362
let (cow, _, _) =

0 commit comments

Comments
 (0)