Comparing version 3.0.0 to 3.0.1
@@ -13,2 +13,3 @@ "use strict"; | ||
var Res_1 = require("../core/Res"); | ||
var __1 = require("../"); | ||
function HttpClient(request) { | ||
@@ -18,18 +19,4 @@ switch (request.method) { | ||
return get(request); | ||
case "POST": | ||
default: | ||
return wire(request); | ||
case "PUT": | ||
return wire(request); | ||
case "PATCH": | ||
return wire(request); | ||
case "DELETE": | ||
return wire(request); | ||
case "HEAD": | ||
return wire(request); | ||
case "OPTIONS": | ||
return wire(request); | ||
case "TRACE": | ||
return wire(request); | ||
default: | ||
return get(request); | ||
} | ||
@@ -48,3 +35,3 @@ } | ||
res.on('end', function () { | ||
return resolve(new Res_1.Res(res.statusCode, Buffer.concat(chunks).toString(), res.headers)); | ||
return resolve(__1.ResOf(res.statusCode, Buffer.concat(chunks).toString(), res.headers)); | ||
}); | ||
@@ -51,0 +38,0 @@ }).end(); |
import * as http from "http"; | ||
import {Res} from "../core/Res"; | ||
import {Req} from "../core/Req"; | ||
import {HeadersType, ResOf} from "../"; | ||
@@ -9,19 +10,5 @@ export function HttpClient(request: Req): Promise<Res> { | ||
return get(request); | ||
case "POST": | ||
return wire(request); | ||
case "PUT": | ||
return wire(request); | ||
case "PATCH": | ||
return wire(request); | ||
case "DELETE": | ||
return wire(request); | ||
case "HEAD": | ||
return wire(request); | ||
case "OPTIONS": | ||
return wire(request); | ||
case "TRACE": | ||
return wire(request); | ||
default: | ||
return get(request) | ||
return wire(request) | ||
@@ -45,3 +32,3 @@ } | ||
res.on('end', () => { | ||
return resolve(new Res(res.statusCode, Buffer.concat(chunks).toString(), res.headers)); | ||
return resolve(ResOf(res.statusCode, Buffer.concat(chunks).toString(), res.headers as HeadersType)); | ||
}); | ||
@@ -67,3 +54,3 @@ }).end(); | ||
res.on('end', () => { | ||
return resolve(new Res(res.statusCode, Buffer.concat(chunks).toString(), res.headers)); | ||
return resolve(new Res(res.statusCode, Buffer.concat(chunks).toString(), res.headers as HeadersType)); | ||
}); | ||
@@ -70,0 +57,0 @@ }); |
@@ -6,3 +6,3 @@ import { HttpMessage, HeadersType } from "./HttpMessage"; | ||
status: number; | ||
constructor(status?: number, body?: string, headers?: {}); | ||
constructor(status?: number, body?: string, headers?: HeadersType); | ||
header(name: string): string; | ||
@@ -9,0 +9,0 @@ withHeader(name: string, value: string): Res; |
@@ -8,3 +8,3 @@ import {HttpMessage, HeadersType} from "./HttpMessage"; | ||
constructor(status: number = 200, body: string = "", headers: {} = {}) { | ||
constructor(status: number = 200, body: string = "", headers: HeadersType = {}) { | ||
this.status = status; | ||
@@ -11,0 +11,0 @@ this.body = body; |
{ | ||
"name": "http4js", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "A lightweight HTTP toolkit", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
108412
56
2585
3