Comments (8)
Interesting! I don't 100% understand either, but I'm glad you found this clue. If you feel like digging into it, the node.js api docs for the http module might mention the more subtle differences between res.writeHead and res.statusCode.
from node-ecstatic.
That said, I would accept a pull request if everything seemed to be in (more or less) working order.
from node-ecstatic.
Ok, I'll try to take a look next week.
On 27 Jan 2012, at 17:41, Joshua [email protected] wrote:
Interesting! I don't 100% understand either, but I'm glad you found this clue. If you feel like digging into it, the node.js api docs for the http module might mention the more subtle differences between res.writeHead and res.statusCode.
Reply to this email directly or view it on GitHub:
#25 (comment)
from node-ecstatic.
It seems to be related to the way that the Union module handles responses. If you take a look at this file in union
https://github.com/flatiron/union/blob/master/lib/response-stream.js
You will see that to set a response it actually uses this.response.statusCode. And if I change the code in status-handlers.js to be
res.response.statusCode = 304;
that seems to work.
But I think I prefer the res.writeHead() approach as it reads better. I'll make some changes along those lines and submit a pull request.
Cheers,
Colin
from node-ecstatic.
Interesting. I wonder if you can define the setter for res.statusCode to proxy properly... I haven't tried to do anything quite so tricksy with javascript.
Either way, I approve of the writeHead approach.
from node-ecstatic.
I'm sure you're right and union could be amended to allow the use of re.statusCode directly. But anyway I have submitted a pull request on issue 27 to use writeHead. Thanks.
from node-ecstatic.
I merged your pull request afaik, and I made corresponding changes in the v0.2.x branch.
Still, this is a bug with union imo. I'll file it. Thanks!
from node-ecstatic.
Hi,
I'm using 0.1.6 via npm. I've first checked the code and found a different fix, then I found this issue. I'm not sure this is the same thing but in effect I would have created an issue with a similar subject line, so I rather comment on this one.
My test is: request a file, and request it again. Check the headers.
Expected:
- The Request Header contains the "if-modified-since" tag
- on renewed request the status code is 304
Actual Result
- no "if-modified-since"
- status code 200
My setup looks like this:
app.use(flatiron.plugins.http, {
before: [
function (req, res) {
var found = app.router.dispatch(req, res);
if (!found) {
res.emit('next');
}
},
ecstatic(__dirname + '/public', {
autoIndex : false,
cache: 60000 // or "60000, must-revalidate"
})
],
after: []
});
Wenn I change the ecstatic.js code (lines 86pp) to check the 'if-modified-since' header than the status code is returned as I would expect it.
// Return a 304 if necessary
if ( req.headers
&& ( (req.headers['if-none-match'] === etag(stat))
|| (Date.parse(req.headers['if-none-match']) >= stat.mtime )
|| (Date.parse(req.headers['if-modified-since']) <= stat.mtime)
)
) {
console.log("sending 304");
status[304](res, next);
}
When I comment the date comparison of 'if-modified-since' I get back 200 every time with Firefox, if I uncomment it, I get 304.
With Safari however, I always get 200: Safari does never send 'if-modified-since'. I controlled different pages and there this header is sent and 304 is returned, so in general it can work. I've tried adding the 'Expires' header but that did not help.
EDIT:
I've checked the 0.2 branch. The respective code is there in ecstatic/serve.js.
What is the reason for 'if-modified-since' not being checked when determining whether to return 304?
EDIT:
BTW: "if-none-match" can be a list of strings, as well. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Thanks,
Chantal
from node-ecstatic.
Related Issues (20)
- baseDir does not work correctly when mounted non-root, and is not necessary HOT 5
- Unable to run CLI due to invalid line endings on Linux HOT 6
- Serve file with default ext is same name dir cannot be shown HOT 2
- Move off of airbnb for linting
- Does the current charset detector actually even work?
- Revamp the directory structure and shape of imports?
- What version of Node are we targeting? (OutgoingMessage & emit close) HOT 1
- Most status code handlers don't have a way of delegating to next() HOT 1
- Rewrite tests to use pickleback
- npm high severity vulnerability HOT 8
- releases available via npm HOT 76
- Version 1.4.0 gone in npm HOT 2
- Add support for JSON directory indices HOT 2
- ecstatic's Past, Present and Future HOT 17
- Windows Infinite 302 Redirection HOT 1
- continue maintaining ecstatic HOT 4
- Failed to compile while building with webpack as dependency HOT 1
- ecstatic stable version
- Vulnerability
- c2de337332a5137944c117000b13d368ce6e24f6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-ecstatic.