{"action":"created","issue":{"url":"https://api.github.com/repos/pillarjs/send/issues/111","repository_url":"https://api.github.com/repos/pillarjs/send","labels_url":"https://api.github.com/repos/pillarjs/send/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/pillarjs/send/issues/111/comments","events_url":"https://api.github.com/repos/pillarjs/send/issues/111/events","html_url":"https://github.com/pillarjs/send/issues/111","id":159774678,"number":111,"title":"[rfc7233] If-Range: isRangeFresh bug?","user":{"login":"silvioprog","id":1456829,"avatar_url":"https://avatars.githubusercontent.com/u/1456829?v=3","gravatar_id":"","url":"https://api.github.com/users/silvioprog","html_url":"https://github.com/silvioprog","followers_url":"https://api.github.com/users/silvioprog/followers","following_url":"https://api.github.com/users/silvioprog/following{/other_user}","gists_url":"https://api.github.com/users/silvioprog/gists{/gist_id}","starred_url":"https://api.github.com/users/silvioprog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silvioprog/subscriptions","organizations_url":"https://api.github.com/users/silvioprog/orgs","repos_url":"https://api.github.com/users/silvioprog/repos","events_url":"https://api.github.com/users/silvioprog/events{/privacy}","received_events_url":"https://api.github.com/users/silvioprog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-06-11T13:57:35Z","updated_at":"2016-06-11T18:37:23Z","closed_at":null,"body":"Hello,\r\n\r\nI'm testing the `send` module, and I think I found a bug. Consider the following code:\r\n\r\n```js\r\nvar express = require('express');\r\nvar app = express();\r\n\r\napp.get('/', function (req, res, next) {\r\n  res.sendFile('abc123.txt');\r\n}).listen(8080, function () {\r\n  console.log('Listening on port 8080');\r\n});\r\n```\r\n\r\nThe `abc123.txt` content:\r\n```\r\nabc123\r\n```\r\n\r\nAnd my request is:\r\n\r\n```\r\nGET: http://localhost:8080\r\nRange: bytes=2-4\r\nIf-Range: W/\"6-15521ebc6bc\"\r\n```\r\n\r\nSo, the result is:\r\n\r\n```\r\nc12\r\n```\r\n\r\nHowever, conforming rfc7233:\r\n\r\n>  A client MUST NOT generate an If-Range header field containing an **entity-tag that is marked as weak**.\r\n\r\n...\r\n\r\n> ... A valid entity-tag can be distinguished from a valid HTTP-date **by examining the first two characters for a DQUOTE**.\r\n\r\nBut, it seems `isRangeFresh()` looks any ocurrence of `\"` char instead of first ones:\r\n\r\n```js\r\n...\r\n[Line 382]\r\nSendStream.prototype.isRangeFresh = function isRangeFresh(){\r\n  var ifRange = this.req.headers['if-range'];\r\n\r\n  if (!ifRange) return true;\r\n\r\n  return ~ifRange.indexOf('\"')\r\n    ? ~ifRange.indexOf(this.res._headers['etag'])\r\n    : Date.parse(this.res._headers['last-modified']) <= Date.parse(ifRange);\r\n};\r\n...\r\n```\r\n\r\nThe same test on nginx works properly. The hash generated by nginx is `\"575475b3-6\"`, and when I send the `If-Range` with `W/\"575475b3-6\"`, it returns the entire content, conforming rfc."},"comment":{"url":"https://api.github.com/repos/pillarjs/send/issues/comments/225382389","html_url":"https://github.com/pillarjs/send/issues/111#issuecomment-225382389","issue_url":"https://api.github.com/repos/pillarjs/send/issues/111","id":225382389,"user":{"login":"dougwilson","id":67512,"avatar_url":"https://avatars.githubusercontent.com/u/67512?v=3","gravatar_id":"","url":"https://api.github.com/users/dougwilson","html_url":"https://github.com/dougwilson","followers_url":"https://api.github.com/users/dougwilson/followers","following_url":"https://api.github.com/users/dougwilson/following{/other_user}","gists_url":"https://api.github.com/users/dougwilson/gists{/gist_id}","starred_url":"https://api.github.com/users/dougwilson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougwilson/subscriptions","organizations_url":"https://api.github.com/users/dougwilson/orgs","repos_url":"https://api.github.com/users/dougwilson/repos","events_url":"https://api.github.com/users/dougwilson/events{/privacy}","received_events_url":"https://api.github.com/users/dougwilson/received_events","type":"User","site_admin":false},"created_at":"2016-06-11T18:37:23Z","updated_at":"2016-06-11T18:37:23Z","body":"> > Besides you simply noticing that it does not technically conform, can you tell me if this is actually creating an issue with a particular web browser or other client?\r\n\r\n> I'm using the Postman on Google Chrome, but the bug is more related to the rfc conformity, so the problem happens in other clients too, like  curl  by command line.\r\n\r\nSorry, you misunderstood my question. If you are adding those headers yourself, that does not found as a client issue, as you are manually adding those headers and hence is only an issue with you specifically noticing it. What I mean is that,over the course of using this module and a standard client interacting with the web server (i.e. when you are personally not involved in constructing the headers in the request), does this actually exhibit unexpected behavior in a web browser?\r\n\r\nBased on your response, it sounds like the answer is \"no\" and if this is the case, i won't fix this until 1.0.0 of this module, which is unlikely to release for a few more years.\r\n\r\nIf you have a real example of a web browser or other client encountering an actual problem (like it causes a corrupted response, corrupted cache, something), please prove this by providing instruction i can use to reproduce and we can consider adding it before the next major version.\r\n\r\nIf you simply want to improve the conformance with the RFC, then please open a pull request with a patch. In order to comply with the RFC, the isRangeFresh function of our module simply must always return false. Be sure to add new tests as well!\r\n\r\nIf you are not very familiar with JavaScript, that is fine! I'd be happy to fix it, but only if there is a real client issue. If it is just for the RFC technicality,I do not have any interest in fixing it, and unless you can get someone else to help make the patch for you, you're welcome to close this issue."}}
{"actor":{"display_login":"dougwilson"}}