Created
July 16, 2012 00:36
-
-
Save bgnori/3119417 to your computer and use it in GitHub Desktop.
get with apache components
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.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