lundi 22 juillet 2019

Add custom session data to jsoup POST request in clojure

I am testing my first clojure ring application with midje and jsoup. The app uses ring-session to add session for logged-only pages. Session is not a cookie, neither part of the header of the request and I dont know how to add it to perform a post request correctly on logged pages...

A POST request in jsoup is something like:

(-> (Jsoup/connect "http://localhost:3001/sendto")
    (.userAgent "...")
    (.header "Content-Type","application/x-www-form-urlencoded")
    (.data "amount" amount)
    (.data "to" email)
    (.data "sendto-submit" "Send")
    (.post))

Altough this will not work when trying to perform a request against a logged-only url.

I'd have to add the session object, that in my case is something like:

{:session {:auth {:email "name@email.com"}}}

to the request, but so far neither (.cookie) nor (.data) worked...

Any help is suuuuper welcome :)

Aucun commentaire:

Enregistrer un commentaire