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

推荐订阅源

Jina AI
Jina AI
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
J
Java Code Geeks
博客园 - 聂微东
B
Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
腾讯CDC
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Azure Blog
Microsoft Azure Blog
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
美团技术团队
博客园 - Franky
Google DeepMind News
Google DeepMind News
V
V2EX
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
The Cloudflare Blog

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(media): drain ignored download responses · openclaw/o...
vincentkoc · 2026-05-28 · via Recent Commits to openclaw:main

@@ -17,6 +17,9 @@ function createMockHttpExchange() {

1717

statusCode: 0,

1818

headers: {} as Record<string, string>,

1919

});

20+

const originalResume = res.resume.bind(res);

21+

const resume = vi.fn(() => originalResume());

22+

res.resume = resume as typeof res.resume;

2023

const req = {

2124

on: (event: string, handler: (...args: unknown[]) => void) => {

2225

if (event === "error") {

@@ -27,18 +30,40 @@ function createMockHttpExchange() {

2730

end: () => undefined,

2831

destroy: () => res.destroy(),

2932

} as const;

30-

return { req, res };

33+

return { req, res, resume };

3134

}

323533-

function mockRedirectExchange(params: { location?: string }) {

34-

const { req, res } = createMockHttpExchange();

36+

function mockRedirectExchange(params: { body?: string; location?: string }) {

37+

const { req, res, resume } = createMockHttpExchange();

3538

res.statusCode = 302;

3639

res.headers = params.location ? { location: params.location } : {};

3740

return {

3841

req,

42+

resume,

43+

send(cb: (value: unknown) => void) {

44+

setImmediate(() => {

45+

cb(res as unknown);

46+

if (params.body) {

47+

res.write(params.body);

48+

}

49+

res.end();

50+

});

51+

},

52+

};

53+

}

54+55+

function mockHttpStatusExchange(params: { body?: string; statusCode: number }) {

56+

const { req, res, resume } = createMockHttpExchange();

57+

res.statusCode = params.statusCode;

58+

return {

59+

req,

60+

resume,

3961

send(cb: (value: unknown) => void) {

4062

setImmediate(() => {

4163

cb(res as unknown);

64+

if (params.body) {

65+

res.write(params.body);

66+

}

4267

res.end();

4368

});

4469

},

@@ -209,21 +234,74 @@ describe("media store redirects", () => {

209234

expect(getRequestHeaders(1).get("authorization")).toBe("Bearer secret");

210235

});

211236237+

it("drains ignored redirect response bodies before following redirects", async () => {

238+

let redirectResume: ReturnType<typeof vi.fn> | undefined;

239+

let call = 0;

240+

mockRequest.mockImplementation((_url, _opts, cb) => {

241+

call += 1;

242+

if (call === 1) {

243+

const exchange = mockRedirectExchange({

244+

body: "ignored redirect response body",

245+

location: "https://example.com/final",

246+

});

247+

redirectResume = exchange.resume;

248+

exchange.send(cb);

249+

return exchange.req;

250+

}

251+252+

const exchange = mockSuccessfulTextExchange({

253+

text: "redirected",

254+

contentType: "text/plain",

255+

});

256+

exchange.send(cb);

257+

return exchange.req;

258+

});

259+260+

await saveMediaSource("https://example.com/start");

261+262+

expect(redirectResume).toHaveBeenCalledOnce();

263+

});

264+212265

it("fails when redirect response omits location header", async () => {

266+

let redirectResume: ReturnType<typeof vi.fn> | undefined;

213267

mockRequest.mockImplementationOnce((_url, _opts, cb) => {

214-

const exchange = mockRedirectExchange({});

268+

const exchange = mockRedirectExchange({ body: "ignored redirect response body" });

269+

redirectResume = exchange.resume;

215270

exchange.send(cb);

216271

return exchange.req;

217272

});

218273

await expectRedirectSaveFailure("Redirect loop or missing Location header");

274+

expect(redirectResume).toHaveBeenCalledOnce();

219275

});

220276221277

it("fails when redirect location is malformed", async () => {

278+

let redirectResume: ReturnType<typeof vi.fn> | undefined;

222279

mockRequest.mockImplementationOnce((_url, _opts, cb) => {

223-

const exchange = mockRedirectExchange({ location: "http://[" });

280+

const exchange = mockRedirectExchange({

281+

body: "ignored redirect response body",

282+

location: "http://[",

283+

});

284+

redirectResume = exchange.resume;

224285

exchange.send(cb);

225286

return exchange.req;

226287

});

227288

await expectRedirectSaveFailure("Invalid redirect Location header");

289+

expect(redirectResume).toHaveBeenCalledOnce();

290+

});

291+292+

it("drains ignored HTTP error response bodies before failing", async () => {

293+

let errorResume: ReturnType<typeof vi.fn> | undefined;

294+

mockRequest.mockImplementationOnce((_url, _opts, cb) => {

295+

const exchange = mockHttpStatusExchange({

296+

body: "ignored error response body",

297+

statusCode: 500,

298+

});

299+

errorResume = exchange.resume;

300+

exchange.send(cb);

301+

return exchange.req;

302+

});

303+304+

await expectRedirectSaveFailure("HTTP 500 downloading media");

305+

expect(errorResume).toHaveBeenCalledOnce();

228306

});

229307

});