Permalink
Browse files

support HEAD

  • Loading branch information...
1 parent 8c918b6 commit d28fcaec441ba163d740084f404611f97a11df76 @dantebronto committed Feb 1, 2011
Showing with 15 additions and 1 deletion.
  1. +1 −1 lib/picard/request.js
  2. +1 −0 lib/picard/routing.js
  3. +13 −0 spec/basic/basic_spec.js
@@ -79,7 +79,7 @@ var RequestExtensions = {
scope.headers.push([ 'Content-Length', scope.body.length ])
scope.headers.push([ 'Content-Encoding', scope.encoding ])
this.response.writeHead(scope.status, scope.headers)
- this.response.write(scope.body, scope.encoding)
+ if ( this.method != 'HEAD' ) this.response.write(scope.body, scope.encoding)
this.response.end()
},
extractFormParams: function(chunk){
@@ -72,6 +72,7 @@ var Routes = {
case 'POST' : return Routes.postRoutes
case 'PUT' : return Routes.putRoutes
case 'DELETE': return Routes.deleteRoutes
+ case 'HEAD' : return Routes.getRoutes
}
},
add: function(path, handler, routeSet){
@@ -75,3 +75,16 @@ describe('POST', function(){
})
+describe('HEAD', function(){
+
+ it('should support HEAD', function(){
+ testReq('HEAD', '/', function(status, headers, body){
+ expect(status).toMatch(200)
+ expect(headers['content-length']).toEqual('14')
+ expect(body).toMatch('')
+ asyncSpecDone()
+ })
+ asyncSpecWait()
+ })
+
+})

0 comments on commit d28fcae

Please sign in to comment.