summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/integration/mod.rs49
-rw-r--r--cli/tests/testdata/http2_request_url.ts12
-rw-r--r--cli/tests/unit/http_test.ts2
3 files changed, 62 insertions, 1 deletions
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs
index 4ada4ef54..e3450c8a1 100644
--- a/cli/tests/integration/mod.rs
+++ b/cli/tests/integration/mod.rs
@@ -2,6 +2,7 @@
use crate::itest;
use deno_core::url;
+use deno_runtime::deno_fetch::reqwest;
use deno_runtime::deno_net::ops_tls::TlsStream;
use deno_runtime::deno_tls::rustls;
use deno_runtime::deno_tls::webpki;
@@ -1229,3 +1230,51 @@ async fn listen_tls_alpn_fail() {
})
.await;
}
+
+#[tokio::test]
+async fn http2_request_url() {
+ // TLS streams require the presence of an ambient local task set to gracefully
+ // close dropped connections in the background.
+ LocalSet::new()
+ .run_until(async {
+ let mut child = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--unstable")
+ .arg("--quiet")
+ .arg("--allow-net")
+ .arg("--allow-read")
+ .arg("./http2_request_url.ts")
+ .arg("4506")
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let stdout = child.stdout.as_mut().unwrap();
+ let mut buffer = [0; 5];
+ let read = stdout.read(&mut buffer).unwrap();
+ assert_eq!(read, 5);
+ let msg = std::str::from_utf8(&buffer).unwrap();
+ assert_eq!(msg, "READY");
+
+ let cert = reqwest::Certificate::from_pem(include_bytes!(
+ "../testdata/tls/RootCA.crt"
+ ))
+ .unwrap();
+
+ let client = reqwest::Client::builder()
+ .add_root_certificate(cert)
+ .http2_prior_knowledge()
+ .build()
+ .unwrap();
+
+ let res = client.get("http://127.0.0.1:4506").send().await.unwrap();
+ assert_eq!(200, res.status());
+
+ let body = res.text().await.unwrap();
+ assert_eq!(body, "http://127.0.0.1:4506/");
+
+ child.kill().unwrap();
+ child.wait().unwrap();
+ })
+ .await;
+}
diff --git a/cli/tests/testdata/http2_request_url.ts b/cli/tests/testdata/http2_request_url.ts
new file mode 100644
index 000000000..5acff8cc2
--- /dev/null
+++ b/cli/tests/testdata/http2_request_url.ts
@@ -0,0 +1,12 @@
+const listener = Deno.listen({
+ port: Number(Deno.args[0]),
+});
+
+console.log("READY");
+
+for await (const conn of listener) {
+ for await (const { request, respondWith } of Deno.serveHttp(conn)) {
+ const href = new URL(request.url).href;
+ respondWith(new Response(href));
+ }
+}
diff --git a/cli/tests/unit/http_test.ts b/cli/tests/unit/http_test.ts
index 2dc08cfa1..7cca8d89e 100644
--- a/cli/tests/unit/http_test.ts
+++ b/cli/tests/unit/http_test.ts
@@ -607,7 +607,7 @@ unitTest(
for await (const conn of listener) {
const httpConn = Deno.serveHttp(conn);
for await (const { request, respondWith } of httpConn) {
- assertEquals(new URL(request.url).href, "http://127.0.0.1/");
+ assertEquals(new URL(request.url).href, "http://127.0.0.1:4501/");
assertEquals(await request.text(), "");
respondWith(new Response());
}