fix(e2e): ignore loose rpc content length headers · openclaw/openclaw@ea4ddb2
vincentkoc
·
2026-06-19
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1880,6 +1880,38 @@ describe("kitchen-sink RPC process sampling", () => {
|
1880 | 1880 | expect(response.text).not.toHaveBeenCalled(); |
1881 | 1881 | }); |
1882 | 1882 | |
| 1883 | +it("streams HTTP probe responses with non-decimal content-length values", async () => { |
| 1884 | +let readStarted = false; |
| 1885 | +let canceled = false; |
| 1886 | +const response = { |
| 1887 | +headers: new Headers({ |
| 1888 | +"content-length": "1e3", |
| 1889 | +}), |
| 1890 | +body: { |
| 1891 | +getReader() { |
| 1892 | +return { |
| 1893 | +async read() { |
| 1894 | +readStarted = true; |
| 1895 | +return { done: false, value: new Uint8Array(1025) }; |
| 1896 | +}, |
| 1897 | +async cancel() { |
| 1898 | +canceled = true; |
| 1899 | +}, |
| 1900 | +}; |
| 1901 | +}, |
| 1902 | +}, |
| 1903 | +text: vi.fn(async () => "not read"), |
| 1904 | +}; |
| 1905 | + |
| 1906 | +await expect(readBoundedResponseText(response, 1024)).rejects.toMatchObject({ |
| 1907 | +code: "ETOOBIG", |
| 1908 | +message: "fetch response body exceeded 1024 bytes", |
| 1909 | +}); |
| 1910 | +expect(readStarted).toBe(true); |
| 1911 | +expect(canceled).toBe(true); |
| 1912 | +expect(response.text).not.toHaveBeenCalled(); |
| 1913 | +}); |
| 1914 | + |
1883 | 1915 | it("reads bounded response streams", async () => { |
1884 | 1916 | await expect(readBoundedResponseText(new Response('{"status":"live"}'), 1024)).resolves.toBe( |
1885 | 1917 | '{"status":"live"}', |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。