Skip to content

Instantly share code, notes, and snippets.

@tellnes
Last active December 18, 2015 19:09
Show Gist options
  • Save tellnes/5831209 to your computer and use it in GitHub Desktop.
Save tellnes/5831209 to your computer and use it in GitHub Desktop.
http request .write callback is never called if encoding is specified.
var http = require('http')
, assert = require('assert')
var port = 1337
var callbackCalled = false
var server = http.createServer(function (req, res) {
req.pipe(res)
server.close()
})
server.listen(port, function () {
var req = http.request({ port: port, method: 'post' })
req.write('test', 'ascii', function () {
callbackCalled = true
})
})
process.on('exit', function () {
assert(callbackCalled, 'calback was never called')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment