aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2019-01-09 20:14:33 -0400
committerEduardo Julian2019-01-09 20:14:33 -0400
commit3821f5d988b632d5f0918cd752b65b7bf924d00e (patch)
treebd8e3e8dee7812a6348801002875470250d6e817 /stdlib
parent086090d4d5c730415ae781a274d076c035d6084a (diff)
Improved header addition.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/lux/world/net/http/header.lux18
1 files 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"))