Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created January 23, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TooTallNate/3558a59c608fab26bac0 to your computer and use it in GitHub Desktop.
Save TooTallNate/3558a59c608fab26bac0 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
my $file = "logo.png";
my $length = -s $file;
print "Content-type: image/png\n";
print "Content-length: $length \n\n";
binmode STDOUT;
open (FH,'<', $file) || die "Could not open $file: $!";
my $buffer = "";
while (read(FH, $buffer, 10240)) {
print $buffer;
}
var http = require('http');
var cgi = require('./');
var server = http.createServer(
cgi(__dirname + '/hello.cgi')
);
server.listen(5555, function() {
console.log('server listening');
var req = http.request({
port: 5555,
host: '127.0.0.1'
});
req.on('response', function (res) {
console.log(res.headers);
});
req.end();
});
@TooTallNate
Copy link
Author

$ node hello
server listening
{ 'content-type': 'image/png',
  'content-length': '3488 ',
  date: 'Fri, 23 Jan 2015 17:29:31 GMT',
  connection: 'keep-alive' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment