HttpClient

external class HttpClient(source)

Constructors

Link copied to clipboard
constructor(userAgent: String = definedExternally, handlers: ReadonlyArray<RequestHandler> = definedExternally, requestOptions: RequestOptions = definedExternally)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun del(requestUrl: String, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>
Link copied to clipboard
fun dispose()

Needs to be called if keepAlive is set to true in request options.

Link copied to clipboard
fun get(requestUrl: String, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>
Link copied to clipboard
fun getAgent(serverUrl: String): Agent

Gets an http agent. This function is useful when you need an http agent that handles routing through a proxy server - depending upon the url and proxy environment variables.

Link copied to clipboard
fun getAgentDispatcher(serverUrl: String): Any?
Link copied to clipboard
fun <T> getJson(requestUrl: String, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<TypedResponse<T>>

Gets a typed object from an endpoint Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise

Link copied to clipboard
fun head(requestUrl: String, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>
Link copied to clipboard
fun options(requestUrl: String, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>
Link copied to clipboard
fun patch(requestUrl: String, data: String, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>
Link copied to clipboard
fun <T> patchJson(requestUrl: String, obj: Any?, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<TypedResponse<T>>
Link copied to clipboard
fun post(requestUrl: String, data: String, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>
Link copied to clipboard
fun <T> postJson(requestUrl: String, obj: Any?, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<TypedResponse<T>>
Link copied to clipboard
fun put(requestUrl: String, data: String, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>
Link copied to clipboard
fun <T> putJson(requestUrl: String, obj: Any?, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<TypedResponse<T>>
Link copied to clipboard
fun request(verb: String, requestUrl: String, data: String?, headers: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>

Makes a raw http request. All other methods such as get, post, patch, and request ultimately call this. Prefer get, del, post and patch

fun request(verb: String, requestUrl: String, data: ReadableStream?, headers: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>
Link copied to clipboard
Link copied to clipboard
fun requestRawWithCallback(info: RequestInfo, data: String?, onResult: (JsError?, res: HttpClientResponse?) -> Unit)

Raw request with callback.

Link copied to clipboard
fun sendStream(verb: String, requestUrl: String, stream: ReadableStream, additionalHeaders: OutgoingHttpHeaders = definedExternally): Promise<HttpClientResponse>