ngx-restful-client
Version:
The ultimate Angular library to exquisitely declare and implement the REST APIs you'll use in your application.
193 lines (192 loc) • 7.29 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var http_1 = require("@angular/common/http");
var utils_1 = require("../utils");
var fromKeyValue = function (headers) {
return new http_1.HttpHeaders(headers);
};
var HttpHeadersBuilder = /** @class */ (function () {
function HttpHeadersBuilder(headers) {
this._headers = !!headers ? headers : new http_1.HttpHeaders();
}
HttpHeadersBuilder.fresh = function () {
return new HttpHeadersBuilder();
};
HttpHeadersBuilder.fromHeaders = function (headers) {
this.validateArgs(headers);
var hs;
if (headers instanceof HttpHeadersBuilder) {
hs = headers._headers;
}
else if (headers instanceof http_1.HttpHeaders) {
hs = headers;
}
else if (utils_1.CoreUtil.hasAttributes(headers)) {
hs = fromKeyValue(headers);
}
return new HttpHeadersBuilder(hs);
};
HttpHeadersBuilder.validateArgs = function (args) {
if (!args) {
throw new Error('Headers initializer param is mandatory.');
}
};
HttpHeadersBuilder.prototype.build = function () {
return this._headers;
};
Object.defineProperty(HttpHeadersBuilder.prototype, "headers", {
get: function () {
return this._headers;
},
enumerable: true,
configurable: true
});
HttpHeadersBuilder.prototype.append = function (key, value) {
this._headers = this._headers.append(key, value);
return this;
};
HttpHeadersBuilder.prototype.set = function (key, value) {
this._headers = this._headers.set(key, value);
return this;
};
HttpHeadersBuilder.prototype.aIM = function (value) {
return this.append('A-IM', value);
};
HttpHeadersBuilder.prototype.accept = function (value) {
return this.append('Accept', value);
};
HttpHeadersBuilder.prototype.acceptCharset = function (value) {
return this.append('Accept-Charset', value);
};
HttpHeadersBuilder.prototype.acceptDatetime = function (value) {
return this.append('Accept-Datetime', value);
};
HttpHeadersBuilder.prototype.acceptEncoding = function (value) {
return this.append('Accept-Encoding', value);
};
HttpHeadersBuilder.prototype.acceptLanguage = function (value) {
return this.append('Accept-Language', value);
};
HttpHeadersBuilder.prototype.accessControlRequestMethod = function (value) {
return this.append('Access-Control-Request-Method', value);
};
HttpHeadersBuilder.prototype.accessControlRequestHeaders = function (value) {
return this.append('Access-Control-Request-Headers', value);
};
HttpHeadersBuilder.prototype.authorization = function (value) {
return this.append('Authorization', value);
};
HttpHeadersBuilder.prototype.cacheControl = function (value) {
return this.append('Cache-Control', value);
};
HttpHeadersBuilder.prototype.connection = function (value) {
return this.append('Connection', value);
};
HttpHeadersBuilder.prototype.contentEncoding = function (value) {
return this.append('Content-Encoding', value);
};
HttpHeadersBuilder.prototype.contentLength = function (value) {
return this.append('Content-Length', value);
};
HttpHeadersBuilder.prototype.contentMD5 = function (value) {
return this.append('Content-MD5', value);
};
HttpHeadersBuilder.prototype.contentType = function (value) {
return this.append('Content-Type', value);
};
HttpHeadersBuilder.prototype.cookie = function (value) {
return this.append('Cookie', value);
};
HttpHeadersBuilder.prototype.date = function (value) {
return this.append('Date', value);
};
HttpHeadersBuilder.prototype.expect = function (value) {
return this.append('Expect', value);
};
HttpHeadersBuilder.prototype.forwarded = function (value) {
return this.append('Forwarded', value);
};
HttpHeadersBuilder.prototype.from = function (value) {
return this.append('From', value);
};
HttpHeadersBuilder.prototype.host = function (value) {
return this.append('Host', value);
};
HttpHeadersBuilder.prototype.HTTP2Settings = function (value) {
return this.append('HTTP2-Settings', value);
};
HttpHeadersBuilder.prototype.ifMatch = function (value) {
return this.append('If-Match', value);
};
HttpHeadersBuilder.prototype.ifModifiedSince = function (value) {
return this.append('If-Modified-Since', value);
};
HttpHeadersBuilder.prototype.ifNoneMatch = function (value) {
return this.append('If-None-Match', value);
};
HttpHeadersBuilder.prototype.ifRange = function (value) {
return this.append('If-Range', value);
};
HttpHeadersBuilder.prototype.ifUnmodifiedSince = function (value) {
return this.append('If-Unmodified-Since', value);
};
HttpHeadersBuilder.prototype.maxForwards = function (value) {
return this.append('Max-Forwards', value);
};
HttpHeadersBuilder.prototype.origin = function (value) {
return this.append('Origin', value);
};
HttpHeadersBuilder.prototype.pragma = function (value) {
return this.append('Pragma', value);
};
HttpHeadersBuilder.prototype.prefer = function (value) {
return this.append('Prefer', value);
};
HttpHeadersBuilder.prototype.proxyAuthorization = function (value) {
return this.append('Proxy-Authorization', value);
};
HttpHeadersBuilder.prototype.range = function (value) {
return this.append('Range', value);
};
HttpHeadersBuilder.prototype.referer = function (value) {
return this.append('Referer', value);
};
HttpHeadersBuilder.prototype.TE = function (value) {
return this.append('TE', value);
};
HttpHeadersBuilder.prototype.trailer = function (value) {
return this.append('Trailer', value);
};
HttpHeadersBuilder.prototype.transferEncoding = function (value) {
return this.append('Transfer-Encoding', value);
};
HttpHeadersBuilder.prototype.userAgent = function (value) {
return this.append('User-Agent', value);
};
HttpHeadersBuilder.prototype.upgrade = function (value) {
return this.append('Upgrade', value);
};
HttpHeadersBuilder.prototype.via = function (value) {
return this.append('Via', value);
};
HttpHeadersBuilder.prototype.warning = function (value) {
return this.append('Warning', value);
};
HttpHeadersBuilder.prototype.addAll = function (headers) {
var _this = this;
var hs;
if (headers instanceof HttpHeadersBuilder) {
hs = headers._headers;
}
else if (headers instanceof http_1.HttpHeaders) {
hs = headers;
}
else {
hs = fromKeyValue(headers);
}
hs.keys().forEach(function (k) { return _this.append(k, hs.getAll(k)); });
return this;
};
return HttpHeadersBuilder;
}());
exports.HttpHeadersBuilder = HttpHeadersBuilder;