Skip to content

Commit 53f7512

Browse files
thomasballingerConvex, Inc.
authored and
Convex, Inc.
committed
Default user agent for fetch() (#28019)
GitOrigin-RevId: 29a75e422778cb4f3ab2b4571132ee0f02822faa
1 parent 7088932 commit 53f7512

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

crates/common/src/http/fetch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ impl ProxiedFetchClient {
6868
);
6969
builder = builder.proxy(proxy);
7070
}
71+
builder = builder.user_agent("Convex/1.0");
7172
Self {
7273
http_client: builder.build().expect("Failed to build reqwest client"),
7374
internal_http_client: reqwest::Client::new(),

npm-packages/udf-tests/convex/fetch.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default action(async () => {
5353
fetchInitFormDataBody,
5454
fetchInitFormDataBlobFilenameBody,
5555
fetchInitFormDataTextFileBody,
56-
// fetchUserAgent,
56+
fetchUserAgent,
5757
// fetchRequest,
5858
// fetchRequestAcceptHeaders,
5959
// fetchPostBodyString,
@@ -642,15 +642,15 @@ async function fetchInitFormDataTextFileBody() {
642642
assert.strictEqual(await file.text(), await resultFile.text());
643643
}
644644

645-
// async function fetchUserAgent() {
646-
// const data = "Hello World";
647-
// const response = await fetch("http://localhost:4545/echo_server", {
648-
// method: "POST",
649-
// body: new TextEncoder().encode(data),
650-
// });
651-
// assertEquals(response.headers.get("user-agent"), `Deno/${Deno.version.deno}`);
652-
// await response.text();
653-
// }
645+
async function fetchUserAgent() {
646+
const data = "Hello World";
647+
const response = await fetch("http://localhost:4545/echo_server", {
648+
method: "POST",
649+
body: new TextEncoder().encode(data),
650+
});
651+
assert.equal(response.headers.get("user-agent"), `Convex/1.0`);
652+
await response.text();
653+
}
654654

655655
// function bufferServer(addr: string): Promise<Buffer> {
656656
// const [hostname, port] = addr.split(":");

0 commit comments

Comments
 (0)