Skip to content

Commit

Permalink
Fix Handlers.getcookies and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
nguiard committed Oct 10, 2023
1 parent 352bca2 commit f2fda83
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 f2fda83

Please sign in to comment.