{"action":"created","issue":{"url":"https://api.github.com/repos/zostay/P6SGI/issues/29","labels_url":"https://api.github.com/repos/zostay/P6SGI/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/zostay/P6SGI/issues/29/comments","events_url":"https://api.github.com/repos/zostay/P6SGI/issues/29/events","html_url":"https://github.com/zostay/P6SGI/issues/29","id":110903563,"number":29,"title":"Thinking about how to handle protocols directly","user":{"login":"zostay","id":34711,"avatar_url":"https://avatars.githubusercontent.com/u/34711?v=3","gravatar_id":"","url":"https://api.github.com/users/zostay","html_url":"https://github.com/zostay","followers_url":"https://api.github.com/users/zostay/followers","following_url":"https://api.github.com/users/zostay/following{/other_user}","gists_url":"https://api.github.com/users/zostay/gists{/gist_id}","starred_url":"https://api.github.com/users/zostay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zostay/subscriptions","organizations_url":"https://api.github.com/users/zostay/orgs","repos_url":"https://api.github.com/users/zostay/repos","events_url":"https://api.github.com/users/zostay/events{/privacy}","received_events_url":"https://api.github.com/users/zostay/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-12T03:32:39Z","updated_at":"2015-12-09T04:58:38Z","closed_at":null,"body":"One thing I've been wondering about while considering how to implement the first Smack protocol handling bits is how new protocols could be implemented in a generic way. Any protocol that is initiated by an Upgrade is pretty easy. However, some protocols, e.g., HTTP/2, might be started immediately by sending a connection preface that is identifiably separate from HTTP/1.1.\r\n\r\nI just had this really crazy idea. What if, instead of a server handing the application an environment after parsing the header, it just handed the application the environment immediately. All the header bits are blank because the headers are not read, the application must read them instead.\r\n\r\nThen, middleware (or the application if that's how the user rolls) can read the input stream and handle the protocol details as required. Standard middleware could be provided for handling things like SSL, HTTP/1.1, HTTP/2, WebSocket, etc. Anyone can fork or reimplement the middleware to optimize and what-not.\r\n\r\nWhere this breaks down, of course, is in handling things like CGI where the application is not actually sent the headers except by environment. In which case, CGI requires both a server implementation and a protocol implementation that knows where to find the headers.\r\n\r\nI think there's some potential here, but I need look through all the PSGI server implementations I can find to consider the consequences of this."},"comment":{"url":"https://api.github.com/repos/zostay/P6SGI/issues/comments/163109051","html_url":"https://github.com/zostay/P6SGI/issues/29#issuecomment-163109051","issue_url":"https://api.github.com/repos/zostay/P6SGI/issues/29","id":163109051,"user":{"login":"zostay","id":34711,"avatar_url":"https://avatars.githubusercontent.com/u/34711?v=3","gravatar_id":"","url":"https://api.github.com/users/zostay","html_url":"https://github.com/zostay","followers_url":"https://api.github.com/users/zostay/followers","following_url":"https://api.github.com/users/zostay/following{/other_user}","gists_url":"https://api.github.com/users/zostay/gists{/gist_id}","starred_url":"https://api.github.com/users/zostay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zostay/subscriptions","organizations_url":"https://api.github.com/users/zostay/orgs","repos_url":"https://api.github.com/users/zostay/repos","events_url":"https://api.github.com/users/zostay/events{/privacy}","received_events_url":"https://api.github.com/users/zostay/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T04:58:38Z","updated_at":"2015-12-09T04:58:38Z","body":"In my latest 0.7.Draft, I have added the notion of a response protocol, which I like quite a bit. So far I've only introduced \"HTTP\" and \"WebSocket\" as protocols (which will probably be renamed to something more convenient), but I am strongly considering a \"Raw\" protocol, which will work something like WebSocket but with the assumption that the server will frame nothing and just give the application access to the connection. I believe I can pair this with the registration routine (see #34) and eliminate the `p6wx.io` extension entirely."}}