Convert cookies from HTMLUnit to HTTPBuilder?

Posted by Misha Koshelev on Stack Overflow See other posts from Stack Overflow or by Misha Koshelev
Published on 2010-06-09T03:46:58Z Indexed on 2010/06/09 3:52 UTC
Read the original article Hit count: 365

Filed under:
|
|

Dear All:

I am doing this (in Groovy):

def cookies=webClient.cookieManager.cookies
def http=new HTTPBuilder("myurl")
http.request(POST) {
   def headersCookie=''
   cookies.eachWithIndex() { cookie,i->
   if (i>0) {
       headersCookie+='; '
   }
   headersCookie+=cookie.getName()+"="+cookie.getValue()
 }
 headers.'Cookie'=headersCookie

 ...
}

Is there a better/less hacky way?

Thank you Misha

© Stack Overflow or respective owner

Related posts about groovy

Related posts about htmlunit