lloyd / connect-etagify

etagify is connect middleware to add ETag headers to cachable but non-static content.
49 stars 6 forks source link

Etag header very broken #6

Open Macil opened 11 years ago

Macil commented 11 years ago

I don't know if my nginx config or CloudFlare is contributing to this, but I get a strange set of headers instead of an ETag header. Using node v0.8.21 and Express 3.1.0.

HTTP/1.1 200 OK Server: cloudflare-nginx Date: Mon, 04 Mar 2013 05:13:06 GMT Content-Type: application/json; charset=utf-8 0: E 1: T 2: a 3: g X-Powered-By: Express Cache-Control: private ...

gu-stav commented 11 years ago

same here. please fix that.

sansmischevia commented 11 years ago

Seeing the same issues:

0:E
1:T
2:a
3:g
black:ETag
blue:ETag
bold:ETag
Connection:keep-alive
Content-Length:99069
Content-Type:text/html
ashbrener commented 11 years ago

+1

bendytree commented 10 years ago

For anyone seeing this issue - you might be using res.header wrong. If you send it one argument, it's not a getter - it's expecting your one argument to be a hash of key/value pairs (not a string).

So it's interpreting res.header("ETag") as res.header({0:'E', 1:'T', 2:'a', 3:'g'}).

Check out the source:

function (field, val){
  if (2 == arguments.length) {
    if (Array.isArray(val)) val = val.map(String);
    else val = String(val);
    this.setHeader(field, val);
  } else {
    for (var key in field) {
      this.set(key, field[key]);
    }
  }
  return this;
}
analytically commented 10 years ago

+1

ashbrener commented 10 years ago

@analytically we have tried to resolve this in quickdraw which was inspired by etagify, feel free to check it out.