<div dir="ltr">It&#39;s worth noting that HTTP/2 refers to the method header as a special &quot;pseudo-header&quot;.<div><br></div><div>&gt; All HTTP/2 requests MUST include exactly one valid value for the :method, :scheme, and :path pseudo-header fields.</div><div><a href="https://http2.github.io/http2-spec/#rfc.section.8.1.2.3">https://http2.github.io/http2-spec/#rfc.section.8.1.2.3</a><br></div><div><br></div><div>So even though it&#39;s being passed as a &quot;header&quot;, it&#39;s a special header distinct from ones like content-type which could merit it continuing to be a stored property on Request.</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jun 14, 2017 at 2:41 PM Michael Chiu &lt;<a href="mailto:hatsuneyuji@icloud.com">hatsuneyuji@icloud.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div style="word-wrap:break-word"><div>So are we going to write our own http parser?</div><div><br></div><div>If not, I don’t see the benefit of ditching version and method properties since both major/minor version and method are given by the http_parser, and users are expecting to find it in the property since these components are well defined in RFC and guaranteed its existence in a proper http req/res. Hence they deserve to be an independent property.  </div><div><br></div><div>On the other hand, there’s no one guarantee the existence of Content-Type and Content-Length etc header exists in HTTP protocol (I can be wrong).</div></div></div><div style="word-wrap:break-word"><div style="word-wrap:break-word"><div><br></div><div>Michael.</div></div></div><div style="word-wrap:break-word"><div style="word-wrap:break-word"><div><br><div><blockquote type="cite"><div>On Jun 14, 2017, at 6:27 AM, Tanner Nelson via swift-server-dev &lt;<a href="mailto:swift-server-dev@swift.org" target="_blank">swift-server-dev@swift.org</a>&gt; wrote:</div><br class="m_6227882099729220012Apple-interchange-newline"><div><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Jun 14, 2017 at 2:11 PM Helge Heß via swift-server-dev &lt;<a href="mailto:swift-server-dev@swift.org" target="_blank">swift-server-dev@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 14 Jun 2017, at 14:59, Paulo Faria &lt;<a href="mailto:paulo@zewo.io" target="_blank">paulo@zewo.io</a>&gt; wrote:<br>
&gt; You&#39;re completely right we should care about HTTP 2.0 now. But let&#39;s do it one step at a time, or else we won&#39;t get things done. The current topic is the HTTPVersion type. So could you please give your feedback in the HTTPVersion thread about how the current proposal of HTTPversion fits with HTTP 2.0? We should go from lower abstractions to higher abstractions incrementally but definitely considering the upper abstractions. Let&#39;s keep focus and move on! 😊<br>
<br>
I gave my feedback on the type in the this thread already. Struct is fine for me, tuple is OK too. I don’t actually care much as “The HTTP version should only matter for logging purposes”. If it comes with comparison operations and such, something is likely wrong with the API.<br>
<br>
<br>
The only HTTP/2 specific note I have is this thing:<br>
<br>
  From the HTTPRequest API design perspective there is a small<br>
  change in that method/version are just headers in HTTP/2.<br>
  I brought that up before.<br>
  E.g. why does ‘method&#39; deserve a special enum, but not<br>
  content-type etc which is equally important for dispatching<br>
  a request. Either approach is fine though.)<br></blockquote><div><br></div><div>In that case, maybe we ditch the version and method properties in favor of something more generic like:</div><div><br></div><div>(just spitballing some pseudo swift here)</div><div>```swift</div><div><br></div><div><div>    struct Request {</div><div>        ...</div><div>        enum Metadata {</div><div>            case original(major: Int, minor: Int, Method)</div><div>            case headers</div><div>        }</div><div><br></div><div>        var metadata: Metadata</div><div>        ...</div><div>    }</div><div><br></div><div><br></div><div>    extension Request {</div><div>        var method: Method {</div><div>            switch metadata {</div><div>            case .original(_, _, let method):</div><div>                return method</div><div>            case .headers:</div><div>                return Method(rawValue: headers[&quot;Method&quot;])</div><div>            }</div><div>        }</div><div>    }</div></div><div><br></div><div>```</div><div>Here an enum&#39;s ability to exhaustively switch would be useful. Then `req.method` is implemented as an extension similar to how `req.version` and `req.contentType` could be implemented.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
This affects the discussion as it may make sense to expose the<br>
HTTPVersion as a regular header to mirror the new HTTP/2 setup<br>
instead of basing the API on the old HTTP/0,1 model.<br>
(I think either is fine, with a slight preference for going<br>
 with the ‘future’)<br>
<br>
Or in other words: Why struct or tuple, just keep it as a string<br>
like the other headers.<br>
<br>
If HTTPVersion is not exposed as a String but as a specific type,<br>
that would then affect the way headers in general are handled<br>
(and I’m very much in favour of NOT using strings for the common<br>
 ones for various reasons).<br>
<br>
hh<br>
<br>
_______________________________________________<br>
swift-server-dev mailing list<br>
<a href="mailto:swift-server-dev@swift.org" target="_blank">swift-server-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-server-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-server-dev</a><br>
</blockquote></div></div>
_______________________________________________<br>swift-server-dev mailing list<br><a href="mailto:swift-server-dev@swift.org" target="_blank">swift-server-dev@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-server-dev" target="_blank">https://lists.swift.org/mailman/listinfo/swift-server-dev</a><br></div></blockquote></div><br></div></div></div></blockquote></div>