Ronan Thibaudau
Ronan Thibaudau

Reputation: 3603

Is it possible to use HTTP2 with HTTPListener

Is it possible to use http2 features with HTTPListeners yet? I didn't hear anything about it but i heard that the new releases of the IIS / asp.net stack support it so i was hoping HTTPListener would be ugpraded too or an alternative would be provided.

If not what would be the best option to support http2, working with raw sockets or is it possible at all to extend httplistener?

Edit : to clarify i'm not just looking for a solution that "reports" http2 but one that enables me to actually use http2 new features such as pushing content, my use case is i have a custom CMS (self written) server that is extremely low latency (replies near instantly to all requests) and the only thing left to optimise is being able to push content AND being able to multiplex as currently the only speedup i can hope for is avoiding the latency from so many rountrips

Upvotes: 9

Views: 1979

Answers (1)

codekaizen
codekaizen

Reputation: 27419

HttpListener is a managed "client" for the Windows kernel module http.sys (similar to how IIS is also a client for it). This version of this module which handles HTTP/2 appears to be only available in Win10 / IE. If you are running on Win10 and an HTTP/2 connection is made, it will likely look the same to HttpListener, since the interface to http.sys driver abstracts the protocol for clients of HttpListener. If anything is different, it would be the HttpListenerResponse.ProtocolVersion showing HTTP/2.

Looking at the source of HttpListener, it seems like the interface to http.sys is blob-oriented, just subscribing to requests and getting the request data in one big blob. This blob forms the basis of the managed HttpListenerContext class, which has the request and response data exposed as properties. The HttpListenerResponse sends the response via http.sys by breaking the data into headers and data chunks which it exposes via the OutputStream property. If multi-streams would be supported, this public API would need to change. It is certainly not currently supported, and my guess is that they won't change this API, and if HTTP/2 will be supported by HttpListener either it will completely abstract HTTP/2 or provide some kind of WriteAsync method to multiplex at this higher level. It sounds like you want to write directly against http.sys to take advantage of lower level features of the protocol.

Upvotes: 10

Related Questions