Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix HEAD requests

The http responses were not ended properly
  • Loading branch information...
commit d8dc9643d0e4eefce820ac08159ed17dd1d09d50 1 parent d9aff72
@kesla authored
Showing with 15 additions and 0 deletions.
  1. +2 −0  main.js
  2. +13 −0 test/test.js
View
2  main.js
@@ -110,6 +110,8 @@ function File (options) {
if (self.src.method !== 'HEAD') {
fs.createReadStream(self.path).pipe(self.dest)
+ } else {
+ self.dest.end()
}
return
}
View
13 test/test.js
@@ -142,6 +142,12 @@ function testhttp () {
x.pipe(resp)
})
+ s.on('/test-head', function (req, resp) {
+ var x = filed(__dirname)
+ req.pipe(x)
+ x.pipe(resp)
+ })
+
s.listen(port, function () {
fs.createReadStream(testfile).pipe(request.put(url+'/test-req'))
@@ -201,6 +207,13 @@ function testhttp () {
console.log("Passed Not Found produces 404")
})
+ request.head(url+'/test-head', function (e, resp) {
+ if (e) throw e
+ if (resp.statusCode !== 200) throw new Error('Status code is not 200 it is'+resp.statusCode)
+ assert.equal(resp.headers['content-type'], 'text/html')
+ console.log("Passed HEAD of directory index")
+ })
+
})
}
Please sign in to comment.
Something went wrong with that request. Please try again.