Created
June 28, 2012 15:18
-
-
Save owainlewis/3011964 to your computer and use it in GitHub Desktop.
Scala Apache HTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.http.client._ | |
import org.apache.http.client.methods._ | |
import org.apache.http.impl.client._ | |
class HTTP { | |
def getRequest: String = { | |
val client = new DefaultHttpClient() | |
val httpGet = new HttpGet("http://www.google.com") | |
val result = try { | |
val response = client.execute(httpGet) | |
"The response status was: " + response.getStatusLine.toString | |
} | |
catch { | |
case _ => "Something went wrong." | |
} | |
return result | |
} | |
} | |
object Client { | |
def main(args : Array[String]) : Unit = { | |
val base = new HTTP | |
val result = base.getRequest | |
println(result) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment