gohttp2

How to read http2 pseudofields


I have an http2 handler and it received http2 requests. Now I need to access :authority pseudoheader field in the request. How to go about it? I am aware of few options as below:

  1. Hijack the http connection -> But I do not want to lose the http layer capabilities, it's really an overkill. All I need is just the value of that pseudo header field.
  2. Get the underlying tcp conn without hijacking it and read the frames from it. -> Now, how to do this? One way could be to get the tcp conn in http.Server.ConnState (but there is no guarantee with this I think. I quite often find that the connection is closed and in any case i find it very cumbersome).

Is there a way, to just extract the pseudofield alone?


Solution

  • the Host in http.Request does it in the sense that, it reads the :authority into r.Host field. But other fields are difficult to get a hold of.