Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ defineGetter(req, 'query', function query(){
var querystring = parse(this).query;

return queryparse(querystring);
});
}, true);

/**
* Check if the incoming request contains the "Content-Type"
Expand Down Expand Up @@ -504,12 +504,19 @@ defineGetter(req, 'xhr', function xhr(){
* @param {Object} obj
* @param {String} name
* @param {Function} getter
* @param {boolean} enableCache
* @private
*/
function defineGetter(obj, name, getter) {
function defineGetter(obj, name, getter, enableCache) {
let cache;
Object.defineProperty(obj, name, {
configurable: true,
enumerable: true,
get: getter
get: function() {
if (typeof cache === "undefined" || !enableCache) {
cache = getter.call(this);
}
return cache;
}
});
}