PluginHttpClient

class PluginHttpClient(threads: Int = DEFAULT_THREADS)(source)

A CIO HttpClient whose engine runs only on threads this plugin owns, so that close can wait for all of its work to finish.

Ktor finishes closing the engine asynchronously - it closes the selector and ends the selector loop after HttpClient.close has returned. On Dispatchers.IO that work could outlive onDisable, and once Paper has closed the plugin JAR it fails with "zip file closed" as soon as it needs a class not loaded yet. Neither piece is a child of a job the client exposes, so joining a job cannot cover them; owning the threads can.

Constructors

Link copied to clipboard
constructor(threads: Int = DEFAULT_THREADS)

Properties

Link copied to clipboard
val client: HttpClient

Functions

Link copied to clipboard
fun close(timeout: Duration): Boolean

Closes the client and blocks until its threads have stopped, or timeout passes. Returns whether they stopped in time.