Skip to content

bug: SetCookieHeader emits invalid Domain (and Path) attributes via Uri.toString() #355

Closed

Description

@nielsenko

Summary

SetCookieHeader in relic_core stores domain and path as Uri? and serializes them with Uri.toString(). This produces invalid Set-Cookie headers, since the Domain attribute must be a bare host (and Path a bare path), not a full URI.

Reported against relic_core ^1.2.0.

Reproduction

Constructing a SetCookieHeader with domain: Uri.parse('http://abc.co') (or Uri.parse('//abc.co')) and encoding it currently yields:

Domain=http://abc.co
Domain=//abc.co

Per RFC 6265 section 4.1.1, Domain is <subdomain>: a plain hostname with no scheme, slashes, port, or path. Browsers may ignore such cookies or behave inconsistently. Expected:

Domain=abc.co

The same shape problem applies to Path, which is also typed as Uri? and serialized with toString().

Source

packages/relic_core/lib/src/headers/typed/headers/set_cookie_header.dart:200-201:

if (domain != null) attributes.add('$_domain${domain.toString()}');
if (path != null) attributes.add('$_path${path.toString()}');

Reported by @vfiruz97 (Slack, 2026-05-18).

Activity

  1. added theissue type on May 19, 2026
  2. added a commit that references this issue on Jun 12, 2026
    87ceb1b
  3. moved this from Inbox 📫 to In Progress 🔥 in Serverpod Frameworkson Jun 12, 2026
  4. added
    bug
    area: headers
    on Jun 12, 2026
  5. moved this from In Progress 🔥 to Done 🚀 in Serverpod Frameworkson Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: headersbug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions