Bastl
Bastl

Reputation: 3006

http session with scala

How can I port this wget stuff to scala:

wget --keep-session-cookies --save-cookies cookies.txt --post-data 'password=xxxx&username=zzzzz' http://server.com/login.jsp
wget --load-cookies cookies.txt http://server.com/download.something

I want to write a tiny, portable script, no external libraries etc.

Can that be done easily ?

Upvotes: 2

Views: 1091

Answers (1)

Sean Parsons
Sean Parsons

Reputation: 2832

Your two main requirements appear to be:

  • Auth with some body text
  • Maintain the session cookies between requests.

Since Scala itself doesn't have much support for HTTP in the core library besides scala.io.Source, you're pretty much stuck with HttpUrlConnection from the Java itself. Looks like this site already has some examples of using HttpUrlConnection in ways like this: Reusing HttpURLConnection so as to keep session alive

Upvotes: 2

Related Questions