Skip to content

Commit

Permalink
1.0.0-beta.1
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Nov 3, 2019
1 parent 763fb5f commit ff7d3d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "http2-wrapper",
"version": "1.0.0-beta.0",
"version": "1.0.0-beta.1",
"description": "HTTP2 client, just with the familiar `https` API",
"main": "source",
"engines": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"coveralls": "^3.0.5",
"create-cert": "^1.0.6",
"get-stream": "^5.1.0",
"got": "^9.6.0",
"got": "^10.0.0-alpha.3",
"lolex": "^4.2.0",
"many-keys-map": "^1.0.2",
"nyc": "^14.1.1",
Expand Down
7 changes: 6 additions & 1 deletion source/agent.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
const EventEmitter = require('events');
const tls = require('tls');
const http2 = require('http2');
const QuickLRU = require('quick-lru');
Expand Down Expand Up @@ -117,8 +118,10 @@ const closeSessionIfCovered = (where, name, coveredSession) => {
}
};

class Agent {
class Agent extends EventEmitter {
constructor({timeout = 60000, maxSessions = Infinity, maxFreeSessions = 1, maxCachedTlsSessions = 100} = {}) {
super();

// A session is considered busy when its current streams count
// is equal to or greater than the `maxConcurrentStreams` value.
this.busySessions = {};
Expand Down Expand Up @@ -430,6 +433,8 @@ class Agent {
return;
}

this.emit('session', session);

if (freeSession()) {
// Process listeners, we're free.
processListeners();
Expand Down
4 changes: 2 additions & 2 deletions source/client-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class ClientRequest extends Writable {

// This event tells we are ready to listen for the data.
this._request.once('response', (headers, flags, rawHeaders) => {
this.res = new IncomingMessage(this.socket);
this.res = new IncomingMessage(this.connection);
this.res.req = this;
this.res.statusCode = headers[HTTP2_HEADER_STATUS];
this.res.headers = headers;
Expand Down Expand Up @@ -271,7 +271,7 @@ class ClientRequest extends Writable {
this.connection = this._request.session.socket;

process.nextTick(() => {
this.emit('socket', this._request.session.socket);
this.emit('socket', this.connection);
});
};

Expand Down

0 comments on commit ff7d3d4

Please sign in to comment.