aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/fetch.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-08 01:05:19 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-10-08 01:06:35 -0700
commitc2c9173eff9e929004d73e087b62ffdc25f0f4ee (patch)
tree06357b3ab4761503d35c0d5aeef294706b4036e0 /test/bun.js/fetch.test.js
parent99e7856269ab084c0b5c69d8dac3bcd89ec08e8d (diff)
downloadbun-c2c9173eff9e929004d73e087b62ffdc25f0f4ee.tar.gz
bun-c2c9173eff9e929004d73e087b62ffdc25f0f4ee.tar.zst
bun-c2c9173eff9e929004d73e087b62ffdc25f0f4ee.zip
Fix https://github.com/oven-sh/bun/issues/1263
What happened: when moving to uSockets for the http client, I forgot to call `SSL_set_tlsext_host_name` and uSockets apparently doesn't do that
Diffstat (limited to 'test/bun.js/fetch.test.js')
-rw-r--r--test/bun.js/fetch.test.js35
1 files changed, 28 insertions, 7 deletions
diff --git a/test/bun.js/fetch.test.js b/test/bun.js/fetch.test.js
index 87d9e0576..1b9d0779e 100644
--- a/test/bun.js/fetch.test.js
+++ b/test/bun.js/fetch.test.js
@@ -2,6 +2,12 @@ import { it, describe, expect } from "bun:test";
import fs from "fs";
import { gc } from "./gc";
+const exampleFixture = fs.readFileSync(
+ import.meta.path.substring(0, import.meta.path.lastIndexOf("/")) +
+ "/fetch.js.txt",
+ "utf8"
+);
+
describe("fetch", () => {
const urls = ["https://example.com", "http://example.com"];
for (let url of urls) {
@@ -12,17 +18,32 @@ describe("fetch", () => {
gc();
const text = await response.text();
gc();
- expect(
- fs.readFileSync(
- import.meta.path.substring(0, import.meta.path.lastIndexOf("/")) +
- "/fetch.js.txt",
- "utf8"
- )
- ).toBe(text);
+ expect(exampleFixture).toBe(text);
});
}
});
+it("simultaneous HTTPS fetch", async () => {
+ const urls = ["https://example.com", "https://www.example.com"];
+ for (let batch = 0; batch < 4; batch++) {
+ const promises = new Array(20);
+ for (let i = 0; i < 20; i++) {
+ promises[i] = fetch(urls[i % 2]);
+ }
+ const result = await Promise.all(promises);
+ expect(result.length).toBe(20);
+ for (let i = 0; i < 20; i++) {
+ expect(result[i].status).toBe(200);
+ expect(await result[i].text()).toBe(exampleFixture);
+ }
+ }
+});
+
+it("website with tlsextname", async () => {
+ // irony
+ await fetch("https://bun.sh", { method: "HEAD" });
+});
+
function testBlobInterface(blobbyConstructor, hasBlobFn) {
for (let withGC of [false, true]) {
for (let jsonObject of [