Skip to content

Commit

Permalink
Fix Handlers.getcookies and add test (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
nguiard authored Oct 11, 2023
1 parent ec7dede commit 5cd586d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Handlers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,6 @@ are expected to be stored in the `req.context[:cookies]` of the
request context as implemented in the [`HTTP.Handlers.cookie_middleware`](@ref)
middleware.
"""
getcookies(req) = get(() => Cookie[], req.context, :cookies)
getcookies(req) = get(() -> Cookie[], req.context, :cookies)

end # module
4 changes: 4 additions & 0 deletions test/handlers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ using HTTP, Test
@test r(HTTP.Request("GET", "/api/widgets/abc/subwidget")) == 15
@test r(HTTP.Request("GET", "/api/widgets/abc/subwidgetname")) == 16

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

0 comments on commit 5cd586d

Please sign in to comment.