pluto-http-client
Version:
HTTP client for NodeJS. Inspired in the Java JAX-RS spec so you can expect excellence, versatility and extensibility.
56 lines (55 loc) • 2.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromMap = exports.HttpHeaders = void 0;
var HttpHeaders;
(function (HttpHeaders) {
HttpHeaders["ACCEPT"] = "Accept";
HttpHeaders["ACCEPT_CHARSET"] = "Accept-Charset";
HttpHeaders["ACCEPT_ENCODING"] = "Accept-Encoding";
HttpHeaders["ACCEPT_LANGUAGE"] = "Accept-Language";
HttpHeaders["ALLOW"] = "Allow";
HttpHeaders["AUTHORIZATION"] = "Authorization";
HttpHeaders["CACHE_CONTROL"] = "Cache-Control";
HttpHeaders["CONTENT_DISPOSITION"] = "Content-Disposition";
HttpHeaders["CONTENT_ENCODING"] = "Content-Encoding";
HttpHeaders["CONTENT_ID"] = "Content-ID";
HttpHeaders["CONTENT_LANGUAGE"] = "Content-Language";
HttpHeaders["CONTENT_LENGTH"] = "Content-Length";
HttpHeaders["CONTENT_LOCATION"] = "Content-Location";
HttpHeaders["CONTENT_TYPE"] = "Content-Type";
HttpHeaders["DATE"] = "Date";
HttpHeaders["ETAG"] = "ETag";
HttpHeaders["EXPECT"] = "Expect";
HttpHeaders["EXPIRES"] = "Expires";
HttpHeaders["HOST"] = "Host";
HttpHeaders["IF_MATCH"] = "If-Match";
HttpHeaders["IF_MODIFIED_SINCE"] = "If-Modified-Since";
HttpHeaders["IF_NONE_MATCH"] = "If-None-Match";
HttpHeaders["IF_UNMODIFIED_SINCE"] = "If-Unmodified-Since";
HttpHeaders["LAST_MODIFIED"] = "Last-Modified";
HttpHeaders["LOCATION"] = "Location";
HttpHeaders["LINK"] = "Link";
HttpHeaders["RETRY_AFTER"] = "Retry-After";
HttpHeaders["USER_AGENT"] = "User-Agent";
HttpHeaders["VARY"] = "Vary";
HttpHeaders["WWW_AUTHENTICATE"] = "WWW-Authenticate";
HttpHeaders["COOKIE"] = "Cookie";
HttpHeaders["SET_COOKIE"] = "Set-Cookie";
HttpHeaders["LAST_EVENT_ID_HEADER"] = "Last-Event-ID";
HttpHeaders["X_REQUEST_ID"] = "X-Request-ID";
HttpHeaders["X_CORRELATION_ID"] = "X-Correlation-ID";
})(HttpHeaders = exports.HttpHeaders || (exports.HttpHeaders = {}));
function fromMap(multiValueMap) {
const obj = {};
for (let [k, headers] of multiValueMap.entries()) {
const values = Array.from(headers.entries()).map(([_, h]) => h.value).join(",");
if (headers.length > 0) {
obj[headers[0].key] = values;
}
else {
obj[k] = values;
}
}
return obj;
}
exports.fromMap = fromMap;