New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http4js

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http4js - npm Package Compare versions

Comparing version 4.2.2 to 4.2.3

1

client/Client.d.ts

@@ -16,2 +16,3 @@ import { HeadersJson, HttpHandler } from "../core/HttpMessage";

static zipkinClientFrom(incomingReq: Req): HttpHandler;
static gzip(): HttpHandler;
}

@@ -5,2 +5,3 @@ "use strict";

var Zipkin_1 = require("../zipkin/Zipkin");
var __1 = require("..");
var Client = /** @class */ (function () {

@@ -16,4 +17,7 @@ function Client() {

};
Client.gzip = function () {
return __1.Filters.GZIP(HttpClient_1.HttpClient);
};
return Client;
}());
exports.Client = Client;

@@ -9,2 +9,3 @@ import {HeadersJson, HttpHandler} from "../core/HttpMessage";

import {Uri} from "../core/Uri";
import {Filter, Filters} from "..";

@@ -31,2 +32,6 @@

}
static gzip(): HttpHandler {
return Filters.GZIP(HttpClient)
}
}

@@ -12,2 +12,3 @@ import { Req } from "./Req";

static ZIPKIN: Filter;
static GZIP: Filter;
}

@@ -14,0 +15,0 @@ export declare function zipkinFilterBuilder(generator: IdGenerator): Filter;

@@ -41,2 +41,4 @@ "use strict";

var Zipkin_1 = require("../zipkin/Zipkin");
var Headers_1 = require("./Headers");
var zlib = require("zlib");
var Filters = /** @class */ (function () {

@@ -59,2 +61,16 @@ function Filters() {

Filters.ZIPKIN = zipkinFilterBuilder(new Zipkin_1.ZipkinIdGenerator());
Filters.GZIP = function (handler) { return function (req) { return __awaiter(_this, void 0, void 0, function () {
var body;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(req.header(Headers_1.Headers.CONTENT_ENCODING) === 'gzip')) return [3 /*break*/, 2];
body = req.bodyStream().pipe(zlib.createGunzip());
return [4 /*yield*/, handler(req.withBody(body))];
case 1: return [2 /*return*/, _a.sent()];
case 2: return [4 /*yield*/, handler(req)];
case 3: return [2 /*return*/, _a.sent()];
}
});
}); }; };
return Filters;

@@ -61,0 +77,0 @@ }());

import {Req} from "./Req";
import {HttpHandler, HeadersJson} from "./HttpMessage";
import {HeadersJson, HttpHandler} from "./HttpMessage";
import {Res} from "./Res";
import {ZipkinIdGenerator, IdGenerator, ZipkinHeaders} from "../zipkin/Zipkin";
import {IdGenerator, ZipkinHeaders, ZipkinIdGenerator} from "../zipkin/Zipkin";
import {Clock} from "./Clock";
import {Headers} from "./Headers";
import * as zlib from "zlib";

@@ -24,2 +26,11 @@ export type Filter = (HttpHandler: HttpHandler) => HttpHandler

static GZIP: Filter = (handler: HttpHandler) => async (req: Req) => {
if (req.header(Headers.CONTENT_ENCODING) === 'gzip') {
const body = req.bodyStream()!.pipe(zlib.createGunzip());
return await handler(req.withBody(body));
} else {
return await handler(req);
}
}
}

@@ -26,0 +37,0 @@

@@ -23,2 +23,3 @@ import { HeadersJson } from "./HttpMessage";

static CONTENT_TYPE: string;
static CONTENT_ENCODING: string;
static FORWARDED: string;

@@ -25,0 +26,0 @@ static HOST: string;

@@ -67,2 +67,3 @@ "use strict";

Headers.CONTENT_TYPE = "Content-Type";
Headers.CONTENT_ENCODING = "Content-Encoding";
Headers.FORWARDED = "Forwarded";

@@ -69,0 +70,0 @@ Headers.HOST = "Host";

@@ -66,2 +66,3 @@ import {HeadersJson} from "./HttpMessage";

static CONTENT_TYPE: string = "Content-Type";
static CONTENT_ENCODING: string = "Content-Encoding";
static FORWARDED: string = "Forwarded";

@@ -68,0 +69,0 @@ static HOST: string = "Host";

2

package.json
{
"name": "http4js",
"version": "4.2.2",
"version": "4.2.3",
"description": "A lightweight HTTP toolkit",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -56,2 +56,4 @@ # http4js

### 4.2.3 Adds gzip filter. Eg. `Filters.GZIP(HttpClient)` or `.withFilter(Filters.GZIP)`
### 4.2.2 throw if no server in Routing when calling start, stop, serveE2E.

@@ -58,0 +60,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc