File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 7575(defn  wrap-input-coercion  [client]
7676  (fn  [{:keys  [body] :as  req}]
7777    (if  (string?  body)
78-       (client  (->  req (assoc  :body  (.toString   body " UTF-8"  )
78+       (client  (->  req (assoc  :body  (.getBytes   body " UTF-8"  )
7979                             :character-encoding  " UTF-8"  )))
8080      (client  req))))
8181
Original file line number Diff line number Diff line change 11(ns  clj-http.client-test 
22  (:use  clojure.test)
33  (:require  [clj-http.client :as  client])
4-   (:require  [clj-http.util :as  util]))
4+   (:require  [clj-http.util :as  util])
5+   (:import  (java.util  Arrays)))
56
67(def  base-req 
78  {:scheme  " http" 
113114    {:uri  " /foo"  }))
114115
115116
117+ (deftest  apply-on-input-coercion 
118+   (let  [i-client (client/wrap-input-coercion  identity)
119+         resp (i-client  {:body  " foo"  })]
120+     (is  (=  " UTF-8"   (:character-encoding  resp)))
121+     (is  (Arrays/equals  (.getBytes  " foo"   " UTF-8"  ) (:body  resp)))))
122+ 
123+ (deftest  pass-on-no-input-coercion 
124+   (is-passed  client/wrap-input-coercion
125+     {:body  (.getBytes  " foo"   " UTF-8"  )}))
126+ 
127+ 
116128(deftest  apply-on-content-type 
117129  (is-applied  client/wrap-content-type
118130    {:content-type  :json }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments