{"action":"created","issue":{"url":"https://api.github.com/repos/httpswift/swifter/issues/66","repository_url":"https://api.github.com/repos/httpswift/swifter","labels_url":"https://api.github.com/repos/httpswift/swifter/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/httpswift/swifter/issues/66/comments","events_url":"https://api.github.com/repos/httpswift/swifter/issues/66/events","html_url":"https://github.com/httpswift/swifter/issues/66","id":121041948,"number":66,"title":"Asynchronous handlers","user":{"login":"vittoriom","id":2075915,"avatar_url":"https://avatars.githubusercontent.com/u/2075915?v=3","gravatar_id":"","url":"https://api.github.com/users/vittoriom","html_url":"https://github.com/vittoriom","followers_url":"https://api.github.com/users/vittoriom/followers","following_url":"https://api.github.com/users/vittoriom/following{/other_user}","gists_url":"https://api.github.com/users/vittoriom/gists{/gist_id}","starred_url":"https://api.github.com/users/vittoriom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vittoriom/subscriptions","organizations_url":"https://api.github.com/users/vittoriom/orgs","repos_url":"https://api.github.com/users/vittoriom/repos","events_url":"https://api.github.com/users/vittoriom/events{/privacy}","received_events_url":"https://api.github.com/users/vittoriom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-12-08T16:15:54Z","updated_at":"2016-05-06T12:21:52Z","closed_at":null,"body":"Hi, we're planning to use your server instead of `GCDWebServer`, but we need to asynchronously handle requests. This means that, when specifying a request handler, we don't want to immediately return a `HttpResponse` but be able to pass this to some kind of completion handler.\r\nDo you think this could be a welcome improvement to the `swifter` project? Also, would you be able to do it?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/httpswift/swifter/issues/comments/217425717","html_url":"https://github.com/httpswift/swifter/issues/66#issuecomment-217425717","issue_url":"https://api.github.com/repos/httpswift/swifter/issues/66","id":217425717,"user":{"login":"fdstevex","id":4220256,"avatar_url":"https://avatars.githubusercontent.com/u/4220256?v=3","gravatar_id":"","url":"https://api.github.com/users/fdstevex","html_url":"https://github.com/fdstevex","followers_url":"https://api.github.com/users/fdstevex/followers","following_url":"https://api.github.com/users/fdstevex/following{/other_user}","gists_url":"https://api.github.com/users/fdstevex/gists{/gist_id}","starred_url":"https://api.github.com/users/fdstevex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdstevex/subscriptions","organizations_url":"https://api.github.com/users/fdstevex/orgs","repos_url":"https://api.github.com/users/fdstevex/repos","events_url":"https://api.github.com/users/fdstevex/events{/privacy}","received_events_url":"https://api.github.com/users/fdstevex/received_events","type":"User","site_admin":false},"created_at":"2016-05-06T12:21:52Z","updated_at":"2016-05-06T12:21:52Z","body":"I ran into this as well, looking to implement a simple proxy server. I want to have Swifter listen and handle the connection, and then my handler will make a connection to somewhere else (different protocol) and stream the data back to the Swifter connection.\r\n\r\nI've done this now by creating my own HttpHandlers extension. The reading I'm doing from the other side is asynchronous, so I have to run it asynchronously.\r\n\r\nI've implemented this by handing off the socket to the stream handler, similar to what the WebSocket handler does, but then HttpServerIO.handleConnection closes the socket as soon as the handler is set up. I hacked it so that if the socket is passed off to the handler it is not closed in handleConnection. That works for me, but it'd be nice to have support for this baked in.\r\n"}}