This repository was archived by the owner on Jul 6, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 58
No closures #23
Closed
Closed
No closures #23
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
more perf updates
- Loading branch information
commit 99a32a9ccf9fea85a9c2e02b16ca26e07d404e12
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1307,17 +1307,19 @@ function initializeTLSOptions(options) { | |
| return options; | ||
| } | ||
|
|
||
| function onErrorSecureServerSession(err, conn) { | ||
| if (!this.emit('clientError', err, conn)) | ||
| conn.destroy(err); | ||
| } | ||
|
|
||
| class Http2SecureServerSession extends TLSServer { | ||
| constructor(options, requestListener) { | ||
| super(initializeTLSOptions(options), connectionListener); | ||
| this[kOptions] = options; | ||
| this.timeout = kDefaultSocketTimeout; | ||
| if (typeof requestListener === 'function') | ||
| this.on('request', requestListener); | ||
| this.on('tlsClientError', (err, conn) => { | ||
| if (!this.emit('clientError', err, conn)) | ||
| conn.destroy(err); | ||
| }); | ||
| this.on('tlsClientError', onErrorSecureServerSession); | ||
| } | ||
|
|
||
| setTimeout(msecs, callback) { | ||
|
|
@@ -1475,9 +1477,8 @@ class Http2ClientSession extends EventEmitter { | |
| this[kSocket] = socket; | ||
|
|
||
| const session = this[kSession] = createClientSession(options, socket); | ||
| socket.once('error', (error) => { | ||
| console.log(error); | ||
| }); | ||
| // TODO remove this | ||
| socket.once('error', console.log); | ||
| socket.on('resume', socketOnResume); | ||
| socket.on('pause', socketOnPause); | ||
| socket.on('drain', socketOnDrain); | ||
|
|
@@ -1605,20 +1606,7 @@ class Http2ClientRequest extends Http2Outgoing { | |
| const _handle = this.stream.session.request(mapToHeaders(this[kHeaders]), true); | ||
| if (_handle instanceof http2.Http2Stream) { | ||
| this[kId] = _handle.getId(); | ||
| this.stream.once('handle', () => { | ||
| if (this[kTrailers] instanceof Map) { | ||
| for (const v of this[kTrailers]) { | ||
| const key = String(v[0]); | ||
| const value = v[1]; | ||
| if (Array.isArray(value) && value.length > 0) { | ||
| for (const item of value) | ||
| this.stream.addTrailer(key, String(item)); | ||
| } else { | ||
| this.stream.addTrailer(key, String(value)); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| this.stream.once('handle', addTrailers) | ||
| this.stream._handle = _handle; | ||
| } | ||
| } | ||
|
|
@@ -1629,6 +1617,22 @@ class Http2ClientRequest extends Http2Outgoing { | |
| } | ||
| } | ||
|
|
||
| function addTrailers () { | ||
| const request = this[kRequest]; | ||
| if (request[kTrailers] instanceof Map) { | ||
| for (const v of request[kTrailers]) { | ||
| const key = String(v[0]); | ||
| const value = v[1]; | ||
| if (Array.isArray(value) && value.length > 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't for of deopt for arrays?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm... I believe it does... (or at least did... I don't know if it still does) |
||
| for (const item of value) | ||
| this.addTrailer(key, String(item)); | ||
| } else { | ||
| this.addTrailer(key, String(value)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class Http2ClientResponse extends Http2Incoming { | ||
| constructor(stream, headers, options) { | ||
| super(stream, headers, options); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use the internal util for this? Is there a chance that the Map was created in a different context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evanlucas ... no, the Map here should always be created in the same context. We could likely just have this be a truthy check to be honest.