clojure - I can pass a cookie in my http post with clj-http -


when use postman handler can cookie without problem, add header, i'm writing test , using clj-http send request rest server, first try hand , add cookie in header

(:status (http/post "http://localhost:8080/create/article"                     {:throw-exceptions false}                     {:body         "...."                      :headers      {"cookie" "uid-session=12"}                      :content-type "application/json"})) 

and try using cookie property

(is (= 200 (:status (http/post "http://localhost:8080/create/article"                                {:throw-exceptions false}                                {:cookies      {"uid-session" {:value "12"}}                                 :body         " ... "                                 :content-type "application/json"})))) 

debugging app handler doesn't receive cookie, reason?...thanks

the problem you're calling http/post incorrectly: you're passing 2 different sets of request options, ignores first one, {:throw-exceptions false}.

(i consider bug in clj-http behaves unhelpfully in case, not signalling error. maybe should open issue...)

if work (at least did me):

(http/post   "http://localhost:8080/create/article"   {:throw-exceptions false    :body "...."    :headers {"cookie" "uid-session=12"}    :content-type "application/json"}) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -