[swift-server-dev] HTTP API v0.1.0

Georgios Moschovitis george.moschovitis at icloud.com
Tue Nov 7 09:51:00 CST 2017


There is also

e) writeHeader => writeHead


> On 7 Nov 2017, at 2:19 PM, Helge Heß via swift-server-dev <swift-server-dev at swift.org> wrote:
> 
> Hi Georgios,
> 
> to summarise your suggestions
> 
> a) Module HTTP        => HTTPServer
> b) HTTPRequest        => HTTPRequestHead
> c) HTTPBodyProcessing => HTTPRequestBodyProcessing
> d) response.done()    => response.close()
> 
> a) I don’t think a) flies, because we might also want to add a client
> 
> b) I suggested that a long time ago and I’m all in for that. Maybe open a PR, I will definitely vote for it (as if I could vote ;-)
> 
> c) this makes no sense to me, because the body processing is the same, whether it would be done in a server or a client.
> 
> d) close() sounds to harsh to me (as if you are forcefully closing the connections, which I think is what `abort` is for).
> I think Node uses `end()`, but I’m also fine w/ .done()
> 
> hh
> 
> On 7. Nov 2017, at 12:30, Georgios Moschovitis <george.moschovitis at icloud.com> wrote:
>> Thanks for the little example, ver helpful. A few naming suggestions stuck me though:
>> 
>> From:
>> 
>> ```
>> import Foundation
>> import HTTP
>> 
>> func hello(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
>> 	response.writeHeader(
>> 		status: .ok,
>> 		headers: [ "Content-Type": "text/html" ])
>> 	)
>> 	response.writeBody("Hello, World!\n")
>> 	response.done()
>> 	return .discardBody
>> }
>> ```
>> 
>> to:
>> 
>> ```
>> import Foundation
>> import HTTPServer
>> 
>> func hello(request: HTTPRequestHead, response: HTTPResponseWriter ) -> HTTPRequestBodyProcessing {
>> 	response.writeHead(
>> 		status: .ok,
>> 		headers: [ "Content-Type": "text/html" ])
>> 	)
>> 	response.writeBody("Hello, World!\n")
>> 	response.close()
>> 	return .discardBody
>> }
>> ```
>> 
>> 
>> what do you think?
>> 
>> 
>> 
>>> On 30 Oct 2017, at 12:08 PM, Helge Heß via swift-server-dev <swift-server-dev at swift.org> wrote:
>>> 
>>> FYI: I updated my Apache implementation of the HTTP API:
>>> 
>>> https://github.com/modswift/http/tree/implementation/mod_swift
>>> 
>>> and wrote up a small blog post on how to use HTTP 0.1.0 with the included server, as well as the above:
>>> 
>>> http://www.alwaysrightinstitute.com/http-010/
>>> 
>>> Have fun!
>>> 
>>> hh
>>> 
>>> P.S.: I also have a GCD based async implementation of the API almost ready. Stay tuned.
>>> 
>>> _______________________________________________
>>> swift-server-dev mailing list
>>> swift-server-dev at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-server-dev
>> 
> 
> _______________________________________________
> swift-server-dev mailing list
> swift-server-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-server-dev



More information about the swift-server-dev mailing list