pluto-http-client
Version:
HTTP client for NodeJS. Inspired in the Java JAX-RS spec so you can expect excellence, versatility and extensibility.
43 lines (42 loc) • 1.26 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Http2Client = exports.Client = void 0;
const url_1 = require("url");
const web_target_1 = require("./web-target");
class Client {
constructor(headers, filters, allowInsecure, timeout, agent) {
this._timeout = timeout;
this._headers = headers;
this._filters = filters;
this._agent = agent;
this._allowInsecure = allowInsecure;
}
target(url) {
return new web_target_1.WebTarget(this, typeof url === "string" ? new url_1.URL(url) : url);
}
get timeout() {
return this._timeout;
}
get headers() {
return this._headers;
}
get filters() {
return this._filters;
}
get agent() {
return this._agent;
}
get allowInsecure() {
return this._allowInsecure;
}
snapshot() {
return new Client(this._headers.clone(), this._filters.clone(), this._allowInsecure, this._timeout, this._agent);
}
}
exports.Client = Client;
class Http2Client extends Client {
target(url) {
return new web_target_1.Http2WebTarget(this.snapshot(), typeof url === "string" ? new url_1.URL(url) : url);
}
}
exports.Http2Client = Http2Client;