{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/http/issues/6","labels_url":"https://api.github.com/repos/nodejs/http/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/http/issues/6/comments","events_url":"https://api.github.com/repos/nodejs/http/issues/6/events","html_url":"https://github.com/nodejs/http/issues/6","id":113627669,"number":6,"title":"Making http \"hookable\"","user":{"login":"jasnell","id":439929,"avatar_url":"https://avatars.githubusercontent.com/u/439929?v=3","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-10-27T16:42:11Z","updated_at":"2015-11-03T18:13:36Z","closed_at":null,"body":"@nodejs/http ... Pulled over to a new issue from https://github.com/nodejs/http/issues/2#issuecomment-151283755\r\n\r\nOne of the possible approaches we can take with the http module is allowing third party modules to systematically replace core functions of the http implementation with their own bits. To do this we would need to:\r\n\r\n* Clearly identify which bits are replaceable\r\n* Clearly define the API / contract that the replacement components would need to implement\r\n* Clearly define the API for registering those replacements \r\n* Refactor the current implementation to make reuse and replacement of key parts easier / possible\r\n\r\nTo keep things as simple as possible, I'd recommend that we identify the replaceable pieces as coarsely as possible. This is just a strawman at this point.... feel free to knock it down.\r\n\r\n* Allow the entire HTTP Parser implementation to be replaced. This would entail wrapping the HTTP Parser into a JS API and providing an API for developers to replace the parser in use (e.g. something like: `const http = require('http'); http.useParser(myParser);`)\r\n* Allow parsing handlers for individual HTTP headers to be registered. This would be part of the new HTTP Parser wrapper API mentioned above. The existing http-parser implementation would need to be modified to use the registered callbacks to parse specific header field values. Custom HTTP parser implementations would be expected to follow the same contract. (e.g. something like: `const http = require('http'); http.onHeader('x-foo', myFooParser);`)\r\n* On the server side, allow the Request handling logic to be replaced. Once the request has been parsed, it's handed off to logic that determines the handling. Alternative implementations would be expected to support the existing API contract but could extend that behavior and provide alternative APIs:\r\n\r\n```\r\n    const http = require('http');\r\n    const myimpl = require('my-implementation');\r\n    // myimpl is a complete reimplementation of the request handling logic, as opposed to \r\n    // just a callback...\r\n    const server = http.createServer(myimpl); \r\n    server.listen(8080);\r\n```\r\n\r\nNot quite sure yet what all would need to happen on the client side... still working through that. Thoughts?"},"comment":{"url":"https://api.github.com/repos/nodejs/http/issues/comments/153441168","html_url":"https://github.com/nodejs/http/issues/6#issuecomment-153441168","issue_url":"https://api.github.com/repos/nodejs/http/issues/6","id":153441168,"user":{"login":"trevnorris","id":289174,"avatar_url":"https://avatars.githubusercontent.com/u/289174?v=3","gravatar_id":"","url":"https://api.github.com/users/trevnorris","html_url":"https://github.com/trevnorris","followers_url":"https://api.github.com/users/trevnorris/followers","following_url":"https://api.github.com/users/trevnorris/following{/other_user}","gists_url":"https://api.github.com/users/trevnorris/gists{/gist_id}","starred_url":"https://api.github.com/users/trevnorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevnorris/subscriptions","organizations_url":"https://api.github.com/users/trevnorris/orgs","repos_url":"https://api.github.com/users/trevnorris/repos","events_url":"https://api.github.com/users/trevnorris/events{/privacy}","received_events_url":"https://api.github.com/users/trevnorris/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T18:13:36Z","updated_at":"2015-11-03T18:13:36Z","body":"I can appreciate not allowing spooky action, but wouldn't any type of http hooks result in the same?"}}