Skip to content

Instantly share code, notes, and snippets.

@bgnori
Created July 16, 2012 00:36
Show Gist options
  • Save bgnori/3119417 to your computer and use it in GitHub Desktop.
Save bgnori/3119417 to your computer and use it in GitHub Desktop.
get with apache components
import org.apache.http.client.methods.HttpGet
import org.apache.http.impl.client.DefaultHttpClient
import org.apache.http.HttpResponse
import org.apache.http.HttpStatus
package something {
object ika {
val client = new DefaultHttpClient
def do_post(u: String): Unit = {
val get = new HttpGet(u)
val response:HttpResponse = client.execute(get)
if (response.getStatusLine.getStatusCode == HttpStatus.SC_OK) {
println(response.getEntity)
}
}
def main(args: Array[String]) {
args match {
case Array(u) => {
this.do_post(u)
}
case _ =>
println("hello apache!")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment