Permalink
Browse files

close #19 by adding HEAD alias for GET requests

  • Loading branch information...
jeremydaly committed Apr 24, 2018
1 parent c4b768b commit 5fdcd32664046b9fda8087b53bf034c5b37a2c46
Showing with 8 additions and 5 deletions.
  1. +6 −3 lib/request.js
  2. +2 −2 lib/response.js
@@ -98,9 +98,12 @@ class REQUEST {
}
} // end for loop

let route = routes['__'+this.method] ? routes['__'+this.method] :
(wildcard && wildcard['__'+this.method] ?
wildcard['__'+this.method] : undefined)
// Alias HEAD to GET method
let method = this.method === 'HEAD' ? 'GET' : this.method

let route = routes['__'+method] ? routes['__'+method] :
(wildcard && wildcard['__'+method] ?
wildcard['__'+method] : undefined)

// Check for the requested method
if (route) {
@@ -353,12 +353,12 @@ class RESPONSE {

// Sends the request to the main callback
send(body) {

// Create the response
const response = {
headers: this._headers,
statusCode: this._statusCode,
body: encodeBody(body),
body: this.app.request.method !== 'HEAD' ? encodeBody(body) : '',
isBase64Encoded: this._isBase64
}

0 comments on commit 5fdcd32

Please sign in to comment.