LoginSignup
0
1

More than 5 years have passed since last update.

kotlin の khttp の使い方 (Post)

Posted at

ソースのダウンロード方法はこちら
kotlin の khttp の使い方 (Get)

http_post.kt
// ------------------------------------------------------------------
/*
    http_post.kt

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

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

    val payload = mapOf("user" to "jiro", "password" to "123456")
    val url : String = "http://httpbin.org/post"
    val rr = post(url,data=payload)
    println(rr)
    println(rr.statusCode)
    println(rr.text)

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

// ------------------------------------------------------------------
Makefile
JAR=../../jar
ORG_JSON=$(JAR)/org.json.jar
http_post.jar: http_post.kt
    kotlinc -cp $(ORG_JSON) http_post.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_post.jar
clean:
    rm -rf http_post.jar

実行コマンド

java -jar http_post.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