This repository was archived by the owner on May 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 101101 req-body (cond
102102 (nil? body)
103103 (RequestBody/create nil " " )
104+
104105 (map? body)
105106 (RequestBody/create (json/write-value-as-string body)
106107 (MediaType/get " application/json; charset=utf-8" ))
108+
107109 (instance? InputStream body)
108110 (stream->req-body body))
109111 req (case method
Original file line number Diff line number Diff line change 9595 (testing " build a post request with a map body"
9696 (let [req (build-request {:method :post
9797 :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) ))))
101101
102102 (testing " build a post request with a stream body"
103103 (let [req (build-request {:method :post
104104 :url " http://aurl"
105105 :body (-> " README.md"
106106 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))))))
110119
111120(deftest fetching-stuff
112121 (testing " normal response"
You can’t perform that action at this time.
0 commit comments