Skip to content
File

Blob: src/workerd/api/tests/warnings-test.js

javascript34 lines
1// Copyright (c) 2026 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5export default {
6 async fetch(request) {
7 // --- FormData body with custom Content-Type (http.c++) ---
8 // The custom Content-Type will lack the boundary parameter that the FormData serializer
9 // generates, preventing the recipient from parsing the body.
10 const formData = new FormData();
11 formData.append('key', 'value');
12 const _req = new Request('http://example.com', {
13 method: 'POST',
14 body: formData,
15 headers: { 'Content-Type': 'multipart/form-data' },
16 });
17 
18 // --- Null-body status with zero-length body (http.c++) ---
19 // Constructing a Response with a null-body status (204) and a non-null, zero-length body
20 // is technically incorrect and should warn.
21 const _resp = new Response('', { status: 204 });
22 
23 return new Response('ok');
24 },
25};
26 
27export const test = {
28 async test(ctrl, env) {
29 // Invoke via service binding so the fetch() handler runs in a traced invocation
30 // (test() handlers are intentionally not traced by the test runner).
31 await env.SELF.fetch('http://dummy');
32 },
33};