You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flatten nested query and form parameter maps (#44)
Brought over flattening code from clj-http but not the options to
enable/disable flattening.
For us, for now, it is always enabled.
See updates to README for examples.
Closes#43
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,9 @@
2
2
3
3
- If specified, request's body encoding is now applied, else defaults to UTF-8 ([#18](https://github.com/clj-commons/clj-http-lite/issues/18)) ([@lread](https://github.com/lread))
4
4
- User info from request URL now applied to basic auth ([#34](https://github.com/clj-commons/clj-http-lite/issues/34)) ([@lread](https://github.com/lread))
5
+
- Nested query and form parameters are now automatically flattened ([#43](https://github.com/clj-commons/clj-http-lite/issues/43)) ([@lread](https://github.com/lread))
5
6
- Quality
7
+
- Docstrings reviewed and updated
6
8
- Automated CI testing added for Windows ([#21](https://github.com/clj-commons/clj-http-lite/issues/21)) ([@lread](https://github.com/lread))
Copy file name to clipboardExpand all lines: README.md
+39-8
Original file line number
Diff line number
Diff line change
@@ -18,11 +18,14 @@ A Clojure HTTP library similar to [clj-http](http://github.com/dakrone/clj-http)
18
18
19
19
- Instead of Apache HttpClient, clj-http-lite uses HttpURLConnection
20
20
- No automatic JSON decoding for response bodies
21
+
- No automatic request body encoding beyond charset and url encoding of form params
21
22
- No cookie support
22
23
- No multipart form uploads
23
24
- No persistent connection support
25
+
- Fewer options
24
26
- namespace rename clj-http.* -> clj-http.lite.*
25
27
28
+
Like its namesake, clj-http-lite is light and simple, but ping us if there is some clj-http feature you'd like to see in clj-http-lite. We can discuss.
26
29
## History
27
30
28
31
- Sep 2011 - [dakrone/clj-http](https://github.com/dakrone/clj-http) created (and is still actively maintained)
@@ -92,6 +95,41 @@ codes.
92
95
The client transparently accepts and decompresses the `gzip` and
93
96
`deflate` content encodings.
94
97
98
+
### Nested params
99
+
100
+
Nested parameter `{:a {:b 1}}` in `:form-params` or `:query-params` is automatically flattened to `a[b]=1`.
101
+
We'll use `httpbin.org` to demonstrate:
102
+
103
+
```clojure
104
+
(-> (client/get"https://httpbin.org/get"
105
+
{:query-params {:one {:two2:three3}}})
106
+
:body
107
+
println)
108
+
{
109
+
"args": {
110
+
"one[three]": "3",
111
+
"one[two]": "2"
112
+
},
113
+
...
114
+
}
115
+
116
+
(-> (client/post"https://httpbin.org/post"
117
+
{:form-params {:one {:two2
118
+
:three {:four {:five5}}}
119
+
:six6}})
120
+
:body
121
+
println)
122
+
{
123
+
...
124
+
"form": {
125
+
"one[three][four][five]": "5",
126
+
"one[two]": "2",
127
+
"six": "6"
128
+
},
129
+
...
130
+
}
131
+
```
132
+
95
133
### Input coercion
96
134
97
135
```clojure
@@ -188,18 +226,11 @@ such), check out the
188
226
189
227
## Known Issues
190
228
191
-
- Nested form params [aren't serialized correctly](https://github.com/hiredman/clj-http-lite/issues/15). There's an easy workaround however:
192
-
193
-
```clojure
194
-
:form-params {"toplevel" {"nested" some-data}} ; doesn't work
195
-
:form-params {"toplevel[nested]" some-data} ; works
196
-
```
197
-
198
229
- If you issue HTTPS connections, [Native Image](https://www.graalvm.org/docs/reference-manual/native-image/) compilation requires an additional parameter in order to enable its support in the generated image.
199
230
200
231
If you get the following kind of error:
201
232
202
-
Exception in thread "main" java.net.MalformedURLException: Accessing an URL protocol that was not enabled.
233
+
Exception in thread "main" java.net.MalformedURLException: Accessing an URL protocol that was not enabled.
203
234
The URL protocol https is supported but not enabled by default. It must be enabled by adding the
204
235
-H:EnableURLProtocols=https option to the native-image command.
0 commit comments