From 3821f5d988b632d5f0918cd752b65b7bf924d00e Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 9 Jan 2019 20:14:33 -0400 Subject: Improved header addition. --- stdlib/source/lux/world/net/http/header.lux | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/stdlib/source/lux/world/net/http/header.lux b/stdlib/source/lux/world/net/http/header.lux index a5dd66748..3a96b37fa 100644 --- a/stdlib/source/lux/world/net/http/header.lux +++ b/stdlib/source/lux/world/net/http/header.lux @@ -1,5 +1,7 @@ (.module: [lux #* + [control + [pipe (#+ case>)]] [data [text format] @@ -9,14 +11,24 @@ ["." mime (#+ MIME)] [// (#+ URL)]]) +(def: #export (add name value) + (-> Text Text Header) + (dictionary.upsert name "" + (|>> (case> + "" + value + + previous + (format previous "," value))))) + (def: #export content-length (-> Nat Header) - (|>> %n (dictionary.put "Content-Length"))) + (|>> %n (..add "Content-Length"))) (def: #export content-type (-> MIME Header) - (|>> mime.name (dictionary.put "Content-Type"))) + (|>> mime.name (..add "Content-Type"))) (def: #export location (-> URL Header) - (dictionary.put "Location")) + (..add "Location")) -- cgit v1.2.3