<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">@Cory<div class="">I do, in fact, mean “zero allocations per request”. I think this is a good thing to strive for, whether as a hard rule or as goal. With regard to your question about parsing, I’ve pushed a prototype of a zero-allocations wrapper for http_parser.c <a href="https://github.com/GeorgeLyon/SwiftHTTPParser" class="">here</a>. There’s a few issues I still need to work through but I think it is enough to communicate the overall gist.</div><div class=""><br class=""></div><div class="">@Helge</div><div class="">I’m handwaving the actual HTTP writing part, but echo and async examples can be found in <a href="https://github.com/GeorgeLyon/Server/blob/master/Sources/Server/main.swift" class="">main.swift</a> now. They are not meaningfully dissimilar from the ones you provided. I would argue avoid the return-a-closure semantic makes them cleaner, but that is just my opinion. </div><div class=""><br class=""></div><div class="">As for back pressure, could you provide a specific use case? It isn’t that I don’t believe back pressure is important, just that there are many places where it can be handled. For instance, the top-level Server object can have a maximum number of open connections of a particular type, or what is now the HTTPWriter can be something else which has a “applyBackpressure” method which synchronizes with the Server under the hood (think wrapping the DispatchQueue argument in your PR in a struct which does `queue.async{ applyBackpressure() }`) without revealing the queue to the handler.</div><div class=""><br class=""><div class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 11, 2017, at 2:59 AM, Helge Heß via swift-server-dev <<a href="mailto:swift-server-dev@swift.org" class="">swift-server-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On 11. Dec 2017, at 02:27, George Leontiev via swift-server-dev <<a href="mailto:swift-server-dev@swift.org" class="">swift-server-dev@swift.org</a>> wrote:<br class=""><blockquote type="cite" class="">With the current design, we effectively guarantee at least one allocation per request because we process the body by returning a closure.<br class=""></blockquote><br class="">Well, while I like the premise, there are *so* many allocations in the current setup (just think about all the Strings in the HTTPRequestHead), this one should really be the last we care about :-)<br class=""><br class=""><br class="">As mentioned before I don’t particularly like the current API, but it is something people could agree on and which I think can do what higher level frameworks require. I’m also fine w/ using a protocol. But it should support the same functionality (or at least allow it at a higher level).<br class=""><br class="">What I miss in your suggestion is a demo on how something complete would look like. I.e., what does the `echo` look like:<br class=""><br class=""> <a href="https://github.com/ZeeZide/http-testserver/blob/master/Sources/http-testserver/main.swift#L54" class="">https://github.com/ZeeZide/http-testserver/blob/master/Sources/http-testserver/main.swift#L54</a><br class=""><br class="">and how would the async wait look like:<br class=""><br class=""> <a href="https://github.com/ZeeZide/http-testserver/blob/master/Sources/http-testserver/main.swift#L111" class="">https://github.com/ZeeZide/http-testserver/blob/master/Sources/http-testserver/main.swift#L111</a><br class=""><br class="">A demo of an echo w/ back-pressure would be cool too.<br class=""><br class="">Note: I’m not expecting working examples here, I would just like to see how you think those would look like in your API.<br class=""><br class="">Thanks,<br class=""> Helge<br class=""><br class=""><br class="">_______________________________________________<br class="">swift-server-dev mailing list<br class=""><a href="mailto:swift-server-dev@swift.org" class="">swift-server-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-server-dev<br class=""></div></div></blockquote></div><br class=""></div></div></div></body></html>