LoginSignup
0
1

More than 5 years have passed since last update.

kotlin の khttp の使い方 (Get)

Posted at

khttp のソースのダウンロード

git clone https://github.com/jkcclemens/khttp.git

org.json.jar のダウンロードはこちら
Download org.json.jar

http_get.kt
// ------------------------------------------------------------------
/*
    http_get.kt

                    Mar/04/2018
*/
// ------------------------------------------------------------------
import khttp.get

fun main(args: Array<out String>) {
    println("*** 開始 ***")

    val url : String = "http://httpbin.org/get"
    val rr = get(url)
    println(rr)
    println(rr.statusCode)
    println(rr.text)

    println("*** 終了 ***")
}

// ------------------------------------------------------------------
Makefile
JAR=../../jar
ORG_JSON=$(JAR)/org.json.jar
http_get.jar: http_get.kt
    kotlinc -cp $(ORG_JSON) http_get.kt \
        khttp/KHttp.kt \
        khttp/responses/Response.kt \
        khttp/responses/GenericResponse.kt \
        khttp/requests/Request.kt \
        khttp/requests/GenericRequest.kt \
        khttp/structures/cookie/Cookie.kt \
        khttp/structures/cookie/CookieJar.kt \
        khttp/structures/files/FileLike.kt \
        khttp/structures/authorization/Authorization.kt \
        khttp/structures/parameters/Parameters.kt \
        khttp/structures/maps/CaseInsensitiveMap.kt \
        khttp/structures/maps/CaseInsensitiveMutableMap.kt \
        khttp/extensions/Extensions.kt \
        -include-runtime -d http_get.jar
clean:
    rm -rf http_get.jar

実行コマンド

java -jar http_get.jar
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1