惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
WordPress大学
WordPress大学
博客园 - Franky
The Cloudflare Blog
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
B
Blog
Y
Y Combinator Blog
V
V2EX
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
博客园 - 司徒正美
IT之家
IT之家
G
Google Developers Blog
C
Check Point Blog
Engineering at Meta
Engineering at Meta
Microsoft Security Blog
Microsoft Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: preserve discord multipart content type · openclaw/o...
steipete · 2026-05-02 · via Recent Commits to openclaw:main

@@ -1,3 +1,5 @@

1+

import { createServer, type Server } from "node:http";

2+

import { fetch as undiciFetch } from "undici";

13

import { afterEach, describe, expect, it, vi } from "vitest";

24

import { serializeRequestBody } from "./rest-body.js";

35

import { RequestClient } from "./rest.js";

@@ -406,6 +408,77 @@ describe("RequestClient", () => {

406408

expect(form.get("files[0]")).toBeInstanceOf(Blob);

407409

});

408410411+

it("dispatches multipart uploads with a multipart/form-data content type", async () => {

412+

const fetchSpy = vi.fn(async (_input: string | URL | Request, init?: RequestInit) => {

413+

expect(init?.headers).toBeInstanceOf(Headers);

414+

expect((init?.headers as Headers).get("Content-Type")).toMatch(

415+

/^multipart\/form-data; boundary=/,

416+

);

417+

expect(init?.body).not.toBeInstanceOf(FormData);

418+

const request = new Request("https://discord.test/upload", {

419+

method: "POST",

420+

headers: init?.headers,

421+

body: init?.body,

422+

});

423+

expect(request.headers.get("Content-Type")).toMatch(/^multipart\/form-data; boundary=/);

424+

return new Response(JSON.stringify({ id: "msg" }), {

425+

status: 200,

426+

headers: { "Content-Type": "application/json" },

427+

});

428+

});

429+

const client = new RequestClient("test-token", { fetch: fetchSpy, queueRequests: false });

430+431+

await expect(

432+

client.post("/channels/c1/messages", {

433+

body: {

434+

content: "file",

435+

files: [{ name: "a.txt", data: new Uint8Array([1]), contentType: "text/plain" }],

436+

},

437+

}),

438+

).resolves.toEqual({ id: "msg" });

439+440+

expect(fetchSpy).toHaveBeenCalledTimes(1);

441+

});

442+443+

it("dispatches multipart uploads through undici fetch with a multipart/form-data content type", async () => {

444+

const server = await new Promise<Server>((resolve) => {

445+

const srv = createServer((req, res) => {

446+

expect(req.headers["content-type"]).toMatch(/^multipart\/form-data; boundary=/);

447+

req.resume();

448+

req.on("end", () => {

449+

res.writeHead(200, { "Content-Type": "application/json" });

450+

res.end(JSON.stringify({ id: "msg" }));

451+

});

452+

});

453+

srv.listen(0, () => resolve(srv));

454+

});

455+

try {

456+

const address = server.address();

457+

if (!address || typeof address === "string") {

458+

throw new Error("test server did not bind to a TCP port");

459+

}

460+

const client = new RequestClient("test-token", {

461+

baseUrl: `http://127.0.0.1:${address.port}`,

462+

apiVersion: 10,

463+

fetch: undiciFetch as unknown as typeof fetch,

464+

queueRequests: false,

465+

});

466+467+

await expect(

468+

client.post("/channels/c1/messages", {

469+

body: {

470+

content: "file",

471+

files: [{ name: "a.txt", data: new Uint8Array([1]), contentType: "text/plain" }],

472+

},

473+

}),

474+

).resolves.toEqual({ id: "msg" });

475+

} finally {

476+

await new Promise<void>((resolve, reject) => {

477+

server.close((err) => (err ? reject(err) : resolve()));

478+

});

479+

}

480+

});

481+409482

it("serializes form multipart uploads for sticker-style endpoints", () => {

410483

const headers = new Headers();

411484

const body = serializeRequestBody(