Skip to content

Commit 5cd586d

Browse files
authored
Fix Handlers.getcookies and add test (#1119)
1 parent ec7dede commit 5cd586d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Handlers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,6 @@ are expected to be stored in the `req.context[:cookies]` of the
496496
request context as implemented in the [`HTTP.Handlers.cookie_middleware`](@ref)
497497
middleware.
498498
"""
499-
getcookies(req) = get(() => Cookie[], req.context, :cookies)
499+
getcookies(req) = get(() -> Cookie[], req.context, :cookies)
500500

501501
end # module

test/handlers.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,8 @@ using HTTP, Test
7777
@test r(HTTP.Request("GET", "/api/widgets/abc/subwidget")) == 15
7878
@test r(HTTP.Request("GET", "/api/widgets/abc/subwidgetname")) == 16
7979

80+
cookie = HTTP.Cookie("abc", "def")
81+
req = HTTP.Request("GET", "/")
82+
req.context[:cookies] = [cookie]
83+
@test HTTP.getcookies(req)[1] == cookie
8084
end

0 commit comments

Comments
 (0)