Skip to content

Instantly share code, notes, and snippets.

@owainlewis
Created June 28, 2012 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owainlewis/3011964 to your computer and use it in GitHub Desktop.
Save owainlewis/3011964 to your computer and use it in GitHub Desktop.
Scala Apache HTTP
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