This repository was archived by the owner on May 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 101
101
req-body (cond
102
102
(nil? body)
103
103
(RequestBody/create nil " " )
104
+
104
105
(map? body)
105
106
(RequestBody/create (json/write-value-as-string body)
106
107
(MediaType/get " application/json; charset=utf-8" ))
108
+
107
109
(instance? InputStream body)
108
110
(stream->req-body body))
109
111
req (case method
Original file line number Diff line number Diff line change 95
95
(testing " build a post request with a map body"
96
96
(let [req (build-request {:method :post
97
97
:url " http://aurl"
98
- :body {:key " value" }})
99
- mime-type ( -> req .body .contentType str)]
100
- ( is ( = " application/json; charset=utf-8 " mime-type ))))
98
+ :body {:key " value" }})]
99
+ ( is ( = " application/json; charset=utf-8 "
100
+ ( -> req .body .contentType str) ))))
101
101
102
102
(testing " build a post request with a stream body"
103
103
(let [req (build-request {:method :post
104
104
:url " http://aurl"
105
105
:body (-> " README.md"
106
106
io/file
107
- io/input-stream)})
108
- mime-type (-> req .body .contentType str)]
109
- (is (= " application/octet-stream" mime-type)))))
107
+ io/input-stream)})]
108
+ (is (= " application/octet-stream"
109
+ (-> req .body .contentType str)))))
110
+
111
+ (testing " build a request with query and header params"
112
+ (let [req (build-request {:url " https://aurl"
113
+ :query {:q1 " v1" :q2 " v2" }
114
+ :header {:h1 " hv1" :h2 " hv2" }})]
115
+ (is (= #{" h1" " h2" }
116
+ (-> req .headers .names)))
117
+ (is (= #{" q1" " q2" }
118
+ (-> req .url .queryParameterNames))))))
110
119
111
120
(deftest fetching-stuff
112
121
(testing " normal response"
You can’t perform that action at this time.
0 commit comments