Skip to content

Commit b314a06

Browse files
quinnjclaude
andcommitted
Write cookie attributes one value per call in stringify
Base's varargs write(io, x1, xs...) iterates a heterogeneous tuple and dispatches each element dynamically, which juliac --trim=safe cannot statically resolve. Cookie stringify used it in four places; writing one value per call is byte-identical in output and compiles to direct calls. The server-side Request rebuild half of this work already landed via #1349. Found trimming a Servo app on Julia nightly (JuliaCon 2026 workshop); together with #1349 this clears the last HTTP-owned verify errors there. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 444b92b commit b314a06

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

src/http_cookies.jl

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,30 @@ function stringify(c::Cookie, isrequest::Bool=true)::String
124124
nm = strip(c.name)
125125
!iscookienamevalid(nm) && return ""
126126
io = IOBuffer()
127-
write(io, sanitizeCookieName(nm), '=', sanitizeCookieValue(c.value))
127+
# One value per `write`: Base's varargs `write(io, x1, xs...)` iterates a
128+
# heterogeneous tuple and dispatches each element dynamically, which
129+
# juliac --trim cannot resolve; single-argument writes are direct.
130+
write(io, sanitizeCookieName(nm))
131+
write(io, '=')
132+
write(io, sanitizeCookieValue(c.value))
128133
if !isrequest
129-
length(c.path) > 0 && write(io, "; Path=", sanitizeCookiePath(c.path))
130-
length(c.domain) > 0 && validCookieDomain(c.domain) && write(io, "; Domain=", c.domain[1] == '.' ? SubString(c.domain, 2) : c.domain)
131-
validCookieExpires(c.expires) && write(io, "; Expires=", Dates.format(c.expires, Dates.RFC1123Format), " GMT")
132-
c.maxage > 0 && write(io, "; Max-Age=", string(c.maxage))
134+
if length(c.path) > 0
135+
write(io, "; Path=")
136+
write(io, sanitizeCookiePath(c.path))
137+
end
138+
if length(c.domain) > 0 && validCookieDomain(c.domain)
139+
write(io, "; Domain=")
140+
write(io, c.domain[1] == '.' ? SubString(c.domain, 2) : c.domain)
141+
end
142+
if validCookieExpires(c.expires)
143+
write(io, "; Expires=")
144+
write(io, Dates.format(c.expires, Dates.RFC1123Format))
145+
write(io, " GMT")
146+
end
147+
if c.maxage > 0
148+
write(io, "; Max-Age=")
149+
write(io, string(c.maxage))
150+
end
133151
c.maxage < 0 && write(io, "; Max-Age=0")
134152
c.httponly && write(io, "; HttpOnly")
135153
c.secure && write(io, "; Secure")

0 commit comments

Comments
 (0)