Add files
This commit is contained in:
commit
a2f355ac82
1757 changed files with 320133 additions and 0 deletions
3
node_modules/http-response-object/lib/headers.d.ts
generated
vendored
Normal file
3
node_modules/http-response-object/lib/headers.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
export declare type Headers = {
|
||||
readonly [name: string]: string | string[];
|
||||
};
|
2
node_modules/http-response-object/lib/headers.js
generated
vendored
Normal file
2
node_modules/http-response-object/lib/headers.js
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
"use strict";
|
||||
exports.__esModule = true;
|
5
node_modules/http-response-object/lib/headers.js.flow
generated
vendored
Normal file
5
node_modules/http-response-object/lib/headers.js.flow
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
// @flow
|
||||
// Generated using flowgen2
|
||||
|
||||
type Headers = {+[name: string]: string | Array<string>};
|
||||
export type {Headers};
|
15
node_modules/http-response-object/lib/index.d.ts
generated
vendored
Normal file
15
node_modules/http-response-object/lib/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { IncomingHttpHeaders } from 'http';
|
||||
/**
|
||||
* A response from a web request
|
||||
*/
|
||||
declare class Response<TBody> {
|
||||
readonly statusCode: number;
|
||||
readonly headers: IncomingHttpHeaders;
|
||||
readonly body: TBody;
|
||||
readonly url: string;
|
||||
constructor(statusCode: number, headers: IncomingHttpHeaders, body: TBody, url: string);
|
||||
isError(): boolean;
|
||||
getBody(encoding: string): string;
|
||||
getBody(): TBody;
|
||||
}
|
||||
export = Response;
|
60
node_modules/http-response-object/lib/index.js
generated
vendored
Normal file
60
node_modules/http-response-object/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
/**
|
||||
* A response from a web request
|
||||
*/
|
||||
var Response = /** @class */ (function () {
|
||||
function Response(statusCode, headers, body, url) {
|
||||
if (typeof statusCode !== 'number') {
|
||||
throw new TypeError('statusCode must be a number but was ' + typeof statusCode);
|
||||
}
|
||||
if (headers === null) {
|
||||
throw new TypeError('headers cannot be null');
|
||||
}
|
||||
if (typeof headers !== 'object') {
|
||||
throw new TypeError('headers must be an object but was ' + typeof headers);
|
||||
}
|
||||
this.statusCode = statusCode;
|
||||
var headersToLowerCase = {};
|
||||
for (var key in headers) {
|
||||
headersToLowerCase[key.toLowerCase()] = headers[key];
|
||||
}
|
||||
this.headers = headersToLowerCase;
|
||||
this.body = body;
|
||||
this.url = url;
|
||||
}
|
||||
Response.prototype.isError = function () {
|
||||
return this.statusCode === 0 || this.statusCode >= 400;
|
||||
};
|
||||
Response.prototype.getBody = function (encoding) {
|
||||
if (this.statusCode === 0) {
|
||||
var err = new Error('This request to ' +
|
||||
this.url +
|
||||
' resulted in a status code of 0. This usually indicates some kind of network error in a browser (e.g. CORS not being set up or the DNS failing to resolve):\n' +
|
||||
this.body.toString());
|
||||
err.statusCode = this.statusCode;
|
||||
err.headers = this.headers;
|
||||
err.body = this.body;
|
||||
err.url = this.url;
|
||||
throw err;
|
||||
}
|
||||
if (this.statusCode >= 300) {
|
||||
var err = new Error('Server responded to ' +
|
||||
this.url +
|
||||
' with status code ' +
|
||||
this.statusCode +
|
||||
':\n' +
|
||||
this.body.toString());
|
||||
err.statusCode = this.statusCode;
|
||||
err.headers = this.headers;
|
||||
err.body = this.body;
|
||||
err.url = this.url;
|
||||
throw err;
|
||||
}
|
||||
if (!encoding || typeof this.body === 'string') {
|
||||
return this.body;
|
||||
}
|
||||
return this.body.toString(encoding);
|
||||
};
|
||||
return Response;
|
||||
}());
|
||||
module.exports = Response;
|
22
node_modules/http-response-object/lib/index.js.flow
generated
vendored
Normal file
22
node_modules/http-response-object/lib/index.js.flow
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
// @flow
|
||||
// Generated using flowgen2
|
||||
|
||||
type IncomingHttpHeaders = Object;
|
||||
|
||||
declare class Response<TBody> {
|
||||
+statusCode: number;
|
||||
+headers: IncomingHttpHeaders;
|
||||
+body: TBody;
|
||||
+url: string;
|
||||
constructor(
|
||||
statusCode: number,
|
||||
headers: IncomingHttpHeaders,
|
||||
body: TBody,
|
||||
url: string,
|
||||
): void;
|
||||
isError(): boolean;
|
||||
getBody(encoding: string): string;
|
||||
getBody(): TBody;
|
||||
}
|
||||
|
||||
module.exports = Response;
|
Loading…
Add table
Add a link
Reference in a new issue