mirror of
https://github.com/sstent/alex_app1.git
synced 2026-01-26 17:12:37 +00:00
lots of work so far-- mostly tidying
This commit is contained in:
47
node_modules/formidable/tool/record.js
generated
vendored
Normal file
47
node_modules/formidable/tool/record.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
var http = require('http');
|
||||
var fs = require('fs');
|
||||
var connections = 0;
|
||||
|
||||
var server = http.createServer(function(req, res) {
|
||||
var socket = req.socket;
|
||||
console.log('Request: %s %s -> %s', req.method, req.url, socket.filename);
|
||||
|
||||
req.on('end', function() {
|
||||
if (req.url !== '/') {
|
||||
res.end(JSON.stringify({
|
||||
method: req.method,
|
||||
url: req.url,
|
||||
filename: socket.filename,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
res.writeHead(200, {'content-type': 'text/html'});
|
||||
res.end(
|
||||
'<form action="/upload" enctype="multipart/form-data" method="post">'+
|
||||
'<input type="text" name="title"><br>'+
|
||||
'<input type="file" name="upload" multiple="multiple"><br>'+
|
||||
'<input type="submit" value="Upload">'+
|
||||
'</form>'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
server.on('connection', function(socket) {
|
||||
connections++;
|
||||
|
||||
socket.id = connections;
|
||||
socket.filename = 'connection-' + socket.id + '.http';
|
||||
socket.file = fs.createWriteStream(socket.filename);
|
||||
socket.pipe(socket.file);
|
||||
|
||||
console.log('--> %s', socket.filename);
|
||||
socket.on('close', function() {
|
||||
console.log('<-- %s', socket.filename);
|
||||
});
|
||||
});
|
||||
|
||||
var port = process.env.PORT || 8080;
|
||||
server.listen(port, function() {
|
||||
console.log('Recording connections on port %s', port);
|
||||
});
|
||||
Reference in New Issue
Block a user