Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tests for HTTP HEAD

  • Loading branch information...
commit c2ae65a2c87d1287b4de59d626e5041641e656b2 1 parent 80bcf27
@mhansen authored
Showing with 28 additions and 5 deletions.
  1. +5 −4 lib/antinode.js
  2. +1 −1  package.json
  3. +22 −0 tests/test-head.js
View
9 lib/antinode.js
@@ -122,6 +122,7 @@ function handle_request(path, req, resp) {
}
else stream_file(path, stats);
} else if (req.method == 'HEAD') {
+ send_headers(200, stats.size, mime.mime_type(path), stats.mtime);
finish(resp);
} else {
return stream_file(path, stats);
@@ -139,15 +140,15 @@ function handle_request(path, req, resp) {
return file_not_found();
}
+ send_headers(200, stats.size, mime.mime_type(file), stats.mtime);
+
req.connection.addListener('timeout', function() {
log.debug('timed out. destroying file read stream');
readStream.destroy();
});
- log.debug("opened",path);
- send_headers(200, stats.size, mime.mime_type(file), stats.mtime);
- req.connection.addListener('drain', function() {
- // it is safe to write
+ readStream.addListener('open', function() {
+ log.debug("opened",path);
});
readStream.addListener('data', function (data) {
// send it out
View
2  package.json
@@ -1,6 +1,6 @@
{ "name" : "antinode"
, "description" : "A simple web server for node.js"
-, "version" : "2.0.5"
+, "version" : "2.0.6"
, "author" : "Mark Hansen <mark@markhansen.co.nz>"
, "contributors" :
[ "Ben Noordhuis <info@bnoordhuis.nl>"
View
22 tests/test-head.js
@@ -0,0 +1,22 @@
+require('./common');
+
+var files = [
+ {"name": "smalltext", "statusCode":200},
+ {"name": "dictionary", "statusCode":200},
+ {"name": "cat.jpg", "statusCode":200},
+ {"name": "iwill404", "statusCode":404}
+];
+
+files.forEach(function (file) {
+ exports[file.name] = function(test) {
+ antinode.start(settings, function() {
+ test_http(test,
+ {'method':'HEAD','pathname':'/'+file.name},
+ {'statusCode':file.statusCode,'body':''},
+ function() {
+ antinode.stop();
+ test.done();
+ });
+ });
+ };
+});
Please sign in to comment.
Something went wrong with that request. Please try again.