aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/world/net/http/header.lux
blob: 8388a0d5de0fa06e11a5629329ee4095b957087d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(.using
  [library
   [lux "*"
    [control
     [pipe {"+" case>}]]
    [data
     [text
      ["%" format {"+" format}]]
     [collection
      ["[0]" dictionary {"+" Dictionary}]]]]]
  [// {"+" Header}
   ["[0]" mime {"+" MIME}]
   [// {"+" URL}]])

(def: .public (has name value)
  (-> Text Text Header)
  (dictionary.revised' name ""
                       (|>> (case>
                             ""
                             value
                             
                             previous
                             (format previous "," value)))))

(def: .public content_length
  (-> Nat Header)
  (|>> %.nat (..has "Content-Length")))

(def: .public content_type
  (-> MIME Header)
  (|>> mime.name (..has "Content-Type")))

(def: .public location
  (-> URL Header)
  (..has "Location"))