#1438: httpkit.client functions (#1439)

* expose query-string function from org.httpkit.client

* add url-encode from httpkit client ns

* cleanup and changelog
This commit is contained in:
Bob 2022-12-06 05:01:52 -05:00 committed by GitHub
parent bd857ae3e1
commit cf01d7f24d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View file

@ -7,6 +7,9 @@ A preview of the next release can be installed from
[Babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting
## Unreleased
- [#1438](https://github.com/babashka/babashka/issues/1438): expose `query-string` and `url-encode` functions from org.httpkit.client ([@bobisageek](https://github.com/bobisageek))
## 1.0.167 (2022-11-30)
- [#1433](https://github.com/babashka/babashka/issues/1433): spec source as built-in fallback. When not including the

View file

@ -72,7 +72,9 @@
'acl (copy-var acl cns)
'unlock (copy-var unlock cns)
'default-client (copy-var client/default-client cns)
'*default-client* default-client})
'*default-client* default-client
'query-string (copy-var client/query-string cns)
'url-encode (copy-var client/url-encode cns)})
(def sni-client-namespace
{'ssl-configurer (copy-var sni-client/ssl-configurer sns)

View file

@ -58,3 +58,14 @@
(deftest alter-var-root-test
(is (alter-var-root (var client/*default-client*) (constantly sni/default-client))))
(deftest query-string-test
(is (= (client/query-string {:k1 "v1" :k2 "v2" :k3 nil :k4 ["v4a" "v4b"] :k5 []})
"k1=v1&k2=v2&k3=&k4=v4a&k4=v4b&k5="))
(is (= (client/query-string {:k1 \v :k2 'v2})
"k1=v&k2=v2")))
(deftest url-encode-test
(is (= "AbC" (client/url-encode "AbC")))
(is (= "%3C%3E%21%40%23%24%25%5E"
(client/url-encode "<>!@#$%^"))))