/
Headers.cljs
137 lines (96 loc) · 4.02 KB
/
Headers.cljs
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
(ns web.fetch.Headers
"The Headers interface of the Fetch API allows you to perform
actions on HTTP request and response headers. These actions include
setting, adding to, and removing. A Headers object has an associated
list, which is initially empty and consists of zero or more name
value pairs. You can add to this using methods like `append()`
Examples.) In all methods of this interface, header names are
by case-insensitive byte sequence."
(:refer-clojure :exclude [get keys set]))
(def constructor
"Constructor.
The Headers() constructor creates a new `web.fetch.Headers` object.
init Optional
An object containing any HTTP headers that you want to pre-populate your Headers object with. This can be a simple object literal with `web.ByteString` values; or an existing Headers object. In the last case, the new Headers object inherits its data from the existing Headers object.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers`"
js/Headers)
(defn append
"Method.
The append() method of the `web.fetch.Headers` interface appends
new value onto an existing header inside a Headers object, or
the header if it does not already exist.
`myHeaders.append(name, value);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/append`"
[this name value]
(-> this (.append name value)))
(defn get-all
"Method.
The getAll() method of the `web.fetch.Headers` interface used
return an array of all the values of a header within a Headers
with a given name; in newer versions of the Fetch spec, it has
deleted, and `Headers.get()` has been updated to fetch all header
instead of only the first one.
`myHeaders.getAll(name);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/getAll`"
[this name]
(-> this (.getAll name)))
(defn delete
"Method.
The delete() method of the `web.fetch.Headers` interface deletes
header from the current Headers object.
`myHeaders.delete(name);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/delete`"
[this name]
(-> this (.delete name)))
(defn entries
"Method.
The Headers.entries() method returns an `iterator` allowing to
through all key/value pairs contained in this object. The both
key and value of each pairs are `web.ByteString` objects.
`headers.entries();`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/entries`"
[this ]
(-> this (.entries)))
(defn get
"Method.
The get() method of the `web.fetch.Headers` interface returns
byte string of all the values of a header within a Headers object
a given name. If the requested header doesn't exist in the Headers
it returns null.
`myHeaders.get(name);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/get`"
[this name]
(-> this (.get name)))
(defn has
"Method.
The has() method of the `web.fetch.Headers` interface returns
boolean stating whether a Headers object contains a certain header.
`myHeaders.has(name);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/has`"
[this name]
(-> this (.has name)))
(defn keys
"Method.
The Headers.keys() method returns an `iterator` allowing to go
all keys contained in this object. The keys are `web.ByteString`
`headers.keys();`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/keys`"
[this ]
(-> this (.keys)))
(defn set
"Method.
The set() method of the `web.fetch.Headers` interface sets a
value for an existing header inside a Headers object, or adds
header if it does not already exist.
`myHeaders.set(name, value);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/set`"
[this name value]
(-> this (.set name value)))
(defn values
"Method.
The Headers.values() method returns an `iterator` allowing to
through all values contained in this object. The values are `web.ByteString`
`headers.values();`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/Headers/values`"
[this ]
(-> this (.values)))