diff --git a/lib/request.js b/lib/request.js index f2bedd0..6443a7c 100644 --- a/lib/request.js +++ b/lib/request.js @@ -269,6 +269,25 @@ class REQUEST { || (wc.length > 1 && this.validWildcard(wc.slice(0,-1))) } + // Gets a header field (case-insensitive) + getHeader(userKey,asArr) { + let key = (userKey || '').toLowerCase() + + return asArr ? this.headers[key] + : this.headers[key] ? + this.headers[key].toString() : undefined + } + + // Returns boolean if header exists + hasHeader(key) { + return this.getHeader(key ? key : '') !== undefined + } + + // Gets a value from the query string + getQuery(key,asArr) { + return asArr ? this.multiValueQuery[key] : this.query[key] + } + } // end REQUEST class // Export the response object