Skip to content

Conversation

@karlseguin
Copy link
Collaborator

This code isn't hooked into anything. It's only a Set-Cookie response header parser (which includes a DateTime parser).

Next step:

  1. Save them in the browser
  2. When sending a request, figure out which cookies should be sent
  3. Include them in the request

I added a testing.zig. I needed a function to assert an integer was within a delta:

test "DateTime: now" {
    const dt = DateTime.now();
    try testing.expectDelta(std.time.microTimestamp(), dt.micros, 1000);
}

std.testing only has this for floats.

It also expands expectEqual to work against strings. I think is nice on its own, but it's particularly useful when testing against an anytype.

fn expectCookieAttributes(attributes: anytype, actual: Cookie) !void {
   inline for (@typeInfo(@TypeOf(attributes)).Struct.fields) |field| {
      testing.expectEqual(@field(anytype, field.name), @field(actual, field.name))
   }
}

This doesn't work with std.expectEqual if any of the values are strings.

@karlseguin karlseguin changed the title Add Set-Cooking parsing Add Set-Cookie parsing Feb 26, 2025
@krichprollsch krichprollsch merged commit c5397bf into lightpanda-io:main Mar 4, 2025
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2025
@karlseguin karlseguin deleted the set_cookie branch March 5, 2025 01:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants