h5bp / server-configs-node

Express / Connect middleware for websites. Goes well with HTML5 Boilerplate.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Defer setHeader/*

ngryman opened this issue · comments

Because other middlewares can generate dynamic content w/ an appropriate content-type but with a custom url, we should defer setting other headers by subscribing to the .on('header', ...) event.

We should continue relying on the given content-type to apply cache and other stuff.

By defering, we also ensure that we have the last word and that nobody will override what we set.

By providing dynamic content, the user takes the responsability to match the correct content-type correctly.

If nobody sets the content-type it should be defaulted to application/octet-stream (the current behavior).