@@ -174,14 +174,16 @@ Body::Body(jsg::Lock& js, kj::Maybe<ExtractedBody> init, Headers& headers)
174174 // The spec allows the user to override the Content-Type, if they wish, so we only set
175175 // the Content-Type if it doesn't already exist.
176176 headers.setCommon (capnp::CommonHeaderName::CONTENT_TYPE, kj::mv (ct));
177- } else if (MimeType::FORM_DATA == ct) {
178- // Custom content-type request/responses with FormData are broken since they require a
179- // boundary parameter only the FormData serializer can provide. Let's warn if a dev does this.
180- IoContext::current ().logWarning (
181- " A FormData body was provided with a custom Content-Type header when constructing "
182- " a Request or Response object. This will prevent the recipient of the Request or "
183- " Response from being able to parse the body. Consider omitting the custom "
184- " Content-Type header." );
177+ } else KJ_IF_SOME (parsed, MimeType::tryParse (ct)) {
178+ if (MimeType::FORM_DATA == parsed) {
179+ // Custom content-type request/responses with FormData are broken since they require a
180+ // boundary parameter only the FormData serializer can provide. Let's warn if a dev does this.
181+ IoContext::current ().logWarning (
182+ " A FormData body was provided with a custom Content-Type header when constructing "
183+ " a Request or Response object. This will prevent the recipient of the Request or "
184+ " Response from being able to parse the body. Consider omitting the custom "
185+ " Content-Type header." );
186+ }
185187 }
186188 }
187189 return kj::mv (i.impl );
@@ -271,7 +273,7 @@ jsg::Promise<kj::String> Body::text(jsg::Lock& js) {
271273 // search-and-replace across your whole site and you forgot that it'll apply to images too.
272274 // When running in the fiddle, let's warn the developer if they do this.
273275 auto & context = IoContext::current ();
274- if (context.isInspectorEnabled ()) {
276+ if (context.hasWarningHandler ()) {
275277 KJ_IF_SOME (type, headersRef.getCommon (js, capnp::CommonHeaderName::CONTENT_TYPE)) {
276278 maybeWarnIfNotText (js, type);
277279 }
@@ -1058,7 +1060,7 @@ jsg::Ref<Response> Response::constructor(jsg::Lock& js,
10581060 " Response with null body status (101, 204, 205, or 304) cannot have a body." );
10591061
10601062 auto & context = IoContext::current ();
1061- if (context.isInspectorEnabled ()) {
1063+ if (context.hasWarningHandler ()) {
10621064 context.logWarning (kj::str (" Constructing a Response with a null body status (" , statusCode,
10631065 " ) and a non-null, "
10641066 " zero-length body. This is technically incorrect, and we recommend you update your "
0 commit comments