Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 563
Ronan Thibaudau Avatar asked May 08 '15 23:05

Ronan Thibaudau


People also ask

What does HttpListener do?

Using the HttpListener class, you can create a simple HTTP protocol listener that responds to HTTP requests.

What is a HTTP listener?

An HTTP listener, also known as a network listener, is a listen socket that has an Internet Protocol (IP) address, a port number, a server name, and a default virtual server. Each virtual server provides connections between the server and clients through one or more listeners.

What is HttpListener C#?

The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web. HttpListener is a simple, programmatically controlled HTTP protocol listener. It can be used to create HTTP servers.


1 Answers

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.

like image 200
codekaizen Avatar answered Sep 22 '22 00:09

codekaizen