如何复制 OkHttp 的 bug [英] How to make a reproduction of a bug for OkHttp
本文介绍了如何复制 OkHttp 的 bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用 OkHttp 重现错误,以便我可以在 StackOverflow 上提交错误或提出问题.
无需大量设置即可完成此操作的最简单方法是什么?
我已阅读
#!line 表示它也将像 shell 脚本一样运行
$ ./example.main.ktsOkHttp======有关文档和 API,请参阅 [项目网站][okhttp]....
I need to reproduce a bug with OkHttp so I can file a bug or ask a question on StackOverflow.
What is the simplest way to do this without a lot of setup?
I've read https://stackoverflow.com/help/how-to-ask and https://stackoverflow.com/help/minimal-reproducible-example but I'm still stuck? Help me!
解决方案
Make a Kotlin script in Intellij, place it outside any source folders and make sure it ends with .main.kts
filename.
example.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)
The #! line means it will run like a shell script also
$ ./example.main.kts
OkHttp
======
See the [project website][okhttp] for documentation and APIs.
...
这篇关于如何复制 OkHttp 的 bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文