Skip to content

Commit

Permalink
LibWeb: Sync statusText check with spec update
Browse files Browse the repository at this point in the history
Synced change from whatwg/fetch#1795.

No functional changes; only update comments to reflect the latest
spec.
  • Loading branch information
F3n67u committed Dec 14, 2024
1 parent b1ae2b9 commit 08ce3fd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Libraries/LibWeb/Fetch/Response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ GC::Ref<Response> Response::create(JS::Realm& realm, GC::Ref<Infrastructure::Res
// https://httpwg.org/specs/rfc9112.html#status.line
static bool is_valid_status_text(String const& status_text)
{
// A status text is a valid status text if it matches the reason-phrase token production.
// A status text is a valid if it is either the empty string or matches the reason-phrase token production.
// reason-phrase = 1*( HTAB / SP / VCHAR / obs-text )
// VCHAR = %x21-7E
// obs-text = %x80-FF
Expand All @@ -107,7 +107,7 @@ WebIDL::ExceptionOr<void> Response::initialize_response(ResponseInit const& init
if (init.status < 200 || init.status > 599)
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::RangeError, "Status must be in range 200-599"sv };

// 2. If init["statusText"] does not match the reason-phrase token production, then throw a TypeError.
// 2. If init["statusText"] is not the empty string and does not match the reason-phrase token production, then throw a TypeError.
if (!is_valid_status_text(init.status_text))
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Invalid statusText: does not match the reason-phrase token production"sv };

Expand Down

0 comments on commit 08ce3fd

Please sign in to comment.