This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 746
etag check middleware missing #224
Comments
嗯,用它吧 |
我找到connect的版本了,是我们的response-patch,然后里面依赖了 response-send |
// ETag support
// TODO: W/ support
if (len > 1024) {
var etag = String(Buffer.isBuffer(body)
? crc.buffer.crc32(body)
: crc.crc32(body));
if (!this.getHeader('ETag')) this.setHeader('ETag', etag);
}
// determine if it's cacheable
var cache = 'GET' == method || 'HEAD' == method;
if (cache) cache = (this.statusCode >= 200 && this.statusCode < 300) || 304 == this.statusCode;
// freshness
if (fresh(req.headers, this._headers) && cache) {
this.statusCode = 304;
}
// strip irrelevant headers
if (204 == this.statusCode || 304 == this.statusCode) {
this.removeHeader('Content-Type');
this.removeHeader('Content-Length');
body = '';
}
// respond
this.end('HEAD' == method ? null : body);
return this; |
我实现一个 koa-fresh |
app.use(etag()); |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: