gpt4 book ai didi

okhttp - 如何重现 OkHttp 的错误

转载 作者:行者123 更新时间:2023-12-01 23:30:26 26 4
gpt4 key购买 nike

我需要用 OkHttp 重现错误,这样我就可以提交错误或在 StackOverflow 上提问。

无需大量设置即可执行此操作的最简单方法是什么?

我读过 https://stackoverflow.com/help/how-to-askhttps://stackoverflow.com/help/minimal-reproducible-example但我还是卡住了?帮帮我!

最佳答案

在 Intellij 中制作一个 Kotlin 脚本,将它放在任何源文件夹之外,并确保它以 .main.kts 文件名结尾。

例子.main.kts

#!/usr/bin/env kotlin

@file:Repository("https://repo1.maven.org/maven2/")
@file:DependsOn("com.squareup.okhttp3:okhttp:4.9.0")
@file:CompilerOptions("-jvm-target", "1.8")

import okhttp3.OkHttpClient
import okhttp3.Request

val client = OkHttpClient()

val request = Request.Builder()
.url("https://raw.github.com/square/okhttp/master/README.md")
.build()

val body = client.newCall(request).execute().use {
it.body!!.string()
}

println(body)

enter image description here

#!行意味着它也将像 shell 脚本一样运行

$ ./example.main.kts          
OkHttp
======

See the [project website][okhttp] for documentation and APIs.
...

关于okhttp - 如何重现 OkHttp 的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66364993/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com