Skip to content

Instantly share code, notes, and snippets.

@gclaramunt
Created June 24, 2009 12:20
Show Gist options
  • Save gclaramunt/135215 to your computer and use it in GitHub Desktop.
Save gclaramunt/135215 to your computer and use it in GitHub Desktop.
package webtest
import java.net._
import scala.xml._
object WebTester {
def open(url:URL):HttpURLConnection = url.openConnection match {
case c:HttpURLConnection => c
case _ => error("Only HTTP connections allowed")
}
def URL( address:String )= new URL(address)
def post(conn:HttpURLConnection, params:String)={
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect()
val dataOutputStream = conn.getOutputStream();
dataOutputStream.write(params.getBytes());
dataOutputStream.close();
conn.getInputStream
}
def get(conn:HttpURLConnection)={
conn.setRequestMethod("GET");
conn.setDoOutput(true);
conn.connect()
conn.getInputStream
}
def sendMsg(smrVer:Int)={
println ("sending message for "+smrVer)
post (open (URL ("localhost:9080/DW2/sendMsg")),"q=SK.SMR.LOAD&m="+smrVer+".01")
}
def main(args:Array[String]): Unit ={
//smrs1 foreach (sendMsg(_))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment