Skip to content
Myr

Added 2xx / 304 check to req.fresh

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 ce7293d · Browse files · 2 files+9 added−4 removed
This commit

State

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

Diff stats

2 files+9 added−4 removed

  • other:+9 added−4 removed

2 files+9 added−4 removed

modified:lib/request.js+8 added-1 removed
388 unmodified lines
389 * @api public390 */391392req.__defineGetter__('fresh', function(){393 var s = this.res.statusCode;394395 // 2xx or 304 as per rfc2616 14.26396 if ((s >= 200 && s < 300) || 304 == s) {393 return fresh(this.headers, this.res._headers);397 return fresh(this.headers, this.res._headers);398 }399400 return false;401});402403/**404 * Check if the request is stale, aka
22 unmodified lines
modified:lib/response.js+1 added-3 removed
111 unmodified lines
112 : crc.crc32(body));113 }114115 // freshness116 if ((this.statusCode >= 200 && this.statusCode < 300) || 304 == this.statusCode) {117 if (req.fresh) this.statusCode = 304;116 if (req.fresh) this.statusCode = 304;118 }117118 // strip irrelevant headers119 if (204 == this.statusCode || 304 == this.statusCode) {120 this.removeHeader('Content-Type');
529 unmodified lines