From 5cd586d8fba2b4208b028aed832104443c1abd07 Mon Sep 17 00:00:00 2001 From: Nicolas Guiard Date: Wed, 11 Oct 2023 11:38:47 +0200 Subject: [PATCH] Fix Handlers.getcookies and add test (#1119) --- src/Handlers.jl | 2 +- test/handlers.jl | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Handlers.jl b/src/Handlers.jl index 88167960a..63fba3457 100644 --- a/src/Handlers.jl +++ b/src/Handlers.jl @@ -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 diff --git a/test/handlers.jl b/test/handlers.jl index c0b7e7ff5..0602e272b 100644 --- a/test/handlers.jl +++ b/test/handlers.jl @@ -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