@httptoolkit/httpolyglot
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -12,2 +12,7 @@ /// <reference types="node" /> | ||
interface Socket { | ||
/** | ||
* Only preserved for types backward compat - always undefined in new releases. | ||
* | ||
* @deprecated | ||
*/ | ||
__httpPeekedData?: Buffer; | ||
@@ -14,0 +19,0 @@ } |
@@ -71,3 +71,3 @@ "use strict"; | ||
connectionListener(socket) { | ||
const data = socket.read(1); | ||
const data = socket.read(); | ||
if (data === null) { | ||
@@ -87,4 +87,2 @@ socket.removeListener('error', onError); | ||
if (firstByte === TLS_HANDSHAKE_BYTE) { | ||
// TLS sockets don't allow half open | ||
socket.allowHalfOpen = false; | ||
this._tlsServer.emit('connection', socket); | ||
@@ -99,7 +97,2 @@ } | ||
else { | ||
// The above unshift isn't always sufficient to invisibly replace the | ||
// read data. The rawPacket property on errors in the clientError event | ||
// for plain HTTP servers loses this data - this prop makes it available. | ||
// Bit of a hacky fix, but sufficient to allow for manual workarounds. | ||
socket.__httpPeekedData = data; | ||
this._httpServer.emit('connection', socket); | ||
@@ -106,0 +99,0 @@ } |
{ | ||
"name": "@httptoolkit/httpolyglot", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"author": "Tim Perry <pimterry@gmail.com>", | ||
@@ -40,3 +40,3 @@ "description": "Serve http and https connections over the same port with node.js", | ||
"dependencies": { | ||
"@types/node": "^16.7.10" | ||
"@types/node": "*" | ||
}, | ||
@@ -43,0 +43,0 @@ "devDependencies": { |
# Httpolyglot [![Build Status](https://github.com/httptoolkit/httpolyglot/workflows/CI/badge.svg)](https://github.com/httptoolkit/httpolyglot/actions) [![Available on NPM](https://img.shields.io/npm/v/@httptoolkit/httpolyglot.svg)](https://npmjs.com/package/@httptoolkit/httpolyglot) | ||
> _Part of [HTTP Toolkit](https://httptoolkit.tech): powerful tools for building, testing & debugging HTTP(S)_ | ||
> _Part of [HTTP Toolkit](https://httptoolkit.com): powerful tools for building, testing & debugging HTTP(S)_ | ||
A module for serving http and https connections over the same port. | ||
A module for serving HTTP, HTTPS and HTTP/2 connections, all over the same port. | ||
Forked from the original [`httpolyglot`](https://github.com/mscdex/httpolyglot) to fix various issues required for [HTTP Toolkit](https://httptoolkit.tech), including: | ||
Forked from the original [`httpolyglot`](https://github.com/mscdex/httpolyglot) to fix various issues required for [HTTP Toolkit](https://httptoolkit.com), including: | ||
* Support for HTTP/2 | ||
* Fixing `tlsClientError`: https://github.com/mscdex/httpolyglot/pull/11. | ||
* Exposing the lost bytes from https://github.com/mscdex/httpolyglot/issues/13 on the socket, as `__httpPeekedData`. | ||
* Dropping support for old versions of Node (and thereby simplifying the code somewhat) | ||
* Fixing `tlsClientError`: https://github.com/mscdex/httpolyglot/pull/11 | ||
* Include initially sniffed bytes aren't lost in subsequent `clientError` events (https://github.com/mscdex/httpolyglot/issues/13) | ||
* Dropping support for very old versions of Node (and thereby simplifying the code somewhat) | ||
* Converting to TypeScript | ||
* Event subscription support (subscribe to `server.on(x, ...)` to hear about `x` from _all_ internal servers - HTTP/2, HTTP/1, TLS and net) | ||
@@ -15,0 +16,0 @@ Requirements |
@@ -11,2 +11,7 @@ import * as net from 'net'; | ||
interface Socket { | ||
/** | ||
* Only preserved for types backward compat - always undefined in new releases. | ||
* | ||
* @deprecated | ||
*/ | ||
__httpPeekedData?: Buffer; | ||
@@ -116,3 +121,3 @@ } | ||
private connectionListener(socket: net.Socket) { | ||
const data = socket.read(1); | ||
const data = socket.read(); | ||
@@ -135,4 +140,2 @@ if (data === null) { | ||
if (firstByte === TLS_HANDSHAKE_BYTE) { | ||
// TLS sockets don't allow half open | ||
socket.allowHalfOpen = false; | ||
this._tlsServer.emit('connection', socket); | ||
@@ -145,7 +148,2 @@ } else { | ||
} else { | ||
// The above unshift isn't always sufficient to invisibly replace the | ||
// read data. The rawPacket property on errors in the clientError event | ||
// for plain HTTP servers loses this data - this prop makes it available. | ||
// Bit of a hacky fix, but sufficient to allow for manual workarounds. | ||
socket.__httpPeekedData = data; | ||
this._httpServer.emit('connection', socket); | ||
@@ -152,0 +150,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86
28762
425
+ Added@types/node@22.9.0(transitive)
+ Addedundici-types@6.19.8(transitive)
- Removed@types/node@16.18.119(transitive)
Updated@types/node@*