Created
July 19, 2012 20:32
-
-
Save FabianFrank/3146587 to your computer and use it in GitHub Desktop.
node 0.6 .abort() crash
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
var http = require('http'); | |
var options = { | |
host: 'www.google.com', | |
port: 80, | |
path: '/upload', | |
method: 'POST' | |
}; | |
var req = http.request(options, function(res) { | |
console.log('STATUS: ' + res.statusCode); | |
console.log('HEADERS: ' + JSON.stringify(res.headers)); | |
res.setEncoding('utf8'); | |
res.on('data', function (chunk) { | |
console.log('BODY: ' + chunk); | |
}); | |
}); | |
req.on('error', function(e) { | |
console.log('problem with request: ' + e.message); | |
}); | |
// write data to request body | |
req.write('data\n'); | |
req.write('data\n'); | |
req.end(); | |
try { | |
req.abort(); | |
} | |
catch (e) { | |
console.log(e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment