-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Nodejs socket read timeouts now honored even after response headers received. * Updates shaky-stream mock to use new Buffer * Changes update type to more accurately reflect a bug fix
- Loading branch information
1 parent
2c1b94e
commit 8904e9c
Showing
7 changed files
with
128 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "bugfix", | ||
"category": "Request", | ||
"description": "Updates node.js request handling to obey socket read timeouts after response headers have been received. Previously timeouts were being ignored once headers were received, sometimes causing connections to hang." | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var stream = require('stream'); | ||
var util = require('util'); | ||
|
||
var Readable = stream.Readable; | ||
|
||
var timeoutFn = typeof setTimeoutOrig === 'function' ? setTimeoutOrig : setTimeout; | ||
|
||
/** | ||
* ShakyStream will send data in 2 parts, pausing between parts. | ||
*/ | ||
function ShakyStream(options) { | ||
if (!(this instanceof ShakyStream)) { | ||
return new ShakyStream(options); | ||
} | ||
if (!options.highWaterMark) { | ||
options.highWaterMark = 1024 * 16; | ||
} | ||
this._shakyTime = options.pauseFor; | ||
this._didStart = false; | ||
this._isPaused = false; | ||
|
||
Readable.call(this, options); | ||
|
||
} | ||
|
||
util.inherits(ShakyStream, Readable); | ||
|
||
ShakyStream.prototype._read = function _read(size) { | ||
if (!this._didStart) { | ||
this._didStart = true; | ||
this.push(new Buffer('{"Count":1,"Items":[{"id":{"S":"2016-12-11"},"dateUTC":{"N":"1481494545591"},')); | ||
} | ||
if (this._didStart && this._isPaused) { | ||
return; | ||
} else if (this._didStart) { | ||
this._isPaused = true; | ||
var self = this; | ||
timeoutFn(function() { | ||
self.push(new Buffer('"javascript":{"M":{"foo":{"S":"bar"},"baz":{"S":"buz"}}}}],"ScannedCount":1}')); | ||
self.push(null); | ||
}, this._shakyTime); | ||
} | ||
}; | ||
|
||
module.exports = ShakyStream; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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