Skip to content
Myr

Removed `req.header(field)`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent 76fd462 · Browse files · 3 files+45 added−57 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+45 added−57 removed

  • tests:+39 added−48 removed
  • other:+6 added−9 removed

3 files+45 added−57 removed

modified:lib/request.js+6 added-9 removed
30 unmodified lines
31 * interchangeable.32 *33 * Examples:34 *35 * req.header('Content-Type');35 * req.get('Content-Type');36 * // => "text/plain"37 * 39 * req.header('content-type');38 * req.get('content-type');39 * // => "text/plain"40 * 43 * req.header('Something');41 * req.get('Something');42 * // => undefined43 * 44 * @param {String} name45 * @return {String} 46 * @api public47 */4851req.header = 49req.get = function(name){50 switch (name = name.toLowerCase()) {51 case 'referer':52 case 'referrer':
30 unmodified lines
83 * @api public84 */8586req.accepts = function(type){90 return utils.accepts(type, this.header('Accept'));87 return utils.accepts(type, this.get('Accept'));88};8990/**91 * Check if the given `charset` is acceptable,
46 unmodified lines
138 * @api public139 */140141req.__defineGetter__('accepted', function(){145 var accept = this.header('Accept');142 var accept = this.get('Accept');143 return accept144 ? utils.parseAccept(accept)145 : [];146});
11 unmodified lines
158 * @api public159 */160161req.__defineGetter__('acceptedLanguages', function(){165 var accept = this.header('Accept-Language');162 var accept = this.get('Accept-Language');163 return accept164 ? utils165 .parseQuality(accept)166 .map(function(obj){
15 unmodified lines
182 * @api public183 */184185req.__defineGetter__('acceptedCharsets', function(){189 var accept = this.header('Accept-Charset');186 var accept = this.get('Accept-Charset');187 return accept188 ? utils189 .parseQuality(accept)190 .map(function(obj){
73 unmodified lines
264 * @api public265 */266267req.is = function(type){271 var ct = this.headers['content-type'];268 var ct = this.get('Content-Type');269 if (!ct) return false;270 ct = ct.split(';')[0];271 if (!~type.indexOf('/')) type = mime.lookup(type);272 if (~type.indexOf('*')) {
89 unmodified lines
added:test/req.get.js+39 added
deleted:test/req.header.js-48 removed