[swift-server-dev] HTTP API Review

Chris Bailey BAILEYC at uk.ibm.com
Mon Sep 11 09:10:21 CDT 2017


Hi Georgios:

I've raised the following PR to carry this discussion forwards:
        https://github.com/swift-server/http/pull/45

The area that's worth discussing is the conversion of
        write(headers:status)
into    write(status:)

The write(status:) call  is a convenience wrapper for writing headers, so 
a side effect is that it may not be obvious that it results in the writing 
of the headers to the socket - i.e. a subsequent call to write(headers:) 
isn't possible.

Chris



From:   Chris Bailey/UK/IBM
To:     Georgios Moschovitis <george.moschovitis at icloud.com>
Cc:     swift-server-dev at swift.org
Date:   10/09/2017 16:09
Subject:        Re: [swift-server-dev] HTTP API Review


Thanks for the feedback Georgios. 

I'll raise a PR for the change of writeHeader()/writeBody() to write() and 
see if there's any objections.

Chris




From:   Georgios Moschovitis <george.moschovitis at icloud.com>
To:     Chris Bailey <BAILEYC at uk.ibm.com>
Cc:     swift-server-dev at swift.org
Date:   09/09/2017 09:17
Subject:        Re: [swift-server-dev] HTTP API Review



>> - `HTTPBodyProcessing` is a very long word with no obvious meaning. 

Agreed, the naming here could be clearer as to what its purpose is. Do you 
have any suggestions? 

Unfortunately, no :(

>> - I would use `HTTPResponse` instead of `HTTPResponseWriter` 

The use of HTTPResponseWriter here is very deliberate because eventually 
the API should be symmetrical for the server and client use cases, ie: a 
server has access to a HTTPRequest and a HTTPResponseWriter, and a client 
has access to a HTTPRequestWriter and a HTTPResponse. 

Hm, that makes sense.

>> - I would rename `writeBody` to `write` (and, maybe, `writeHeader` to 
`addHeader`, `setHeader`, `appendHeader` or something similar) 

I think if we we're to switch to using "write()" for writeBody(), then 
we'd have to move to: 
        func write(headers: HTTPHeaders, status: HTTPResponseStatus, 
completion: @escaping (Result) -> Void) 
        func write(body: UnsafeHTTPResponseBody, completion: @escaping 
(Result) -> Void) 
How does that look? 

Ah, that looks even more Swifty, I like it :-)

-g.



Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-server-dev/attachments/20170911/6b98f9c0/attachment.html>


More information about the swift-server-dev mailing list