简体   繁体   English

如何阅读 http2 伪字段

[英]How to read http2 pseudofields

I have an http2 handler and it received http2 requests.我有一个 http2 处理程序,它收到了 http2 请求。 Now I need to access:authority pseudoheader field in the request.现在我需要访问:请求中的权限伪标题字段。 How to go about it?怎么go一下呢? 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.劫持 http 连接 -> 但我不想失去 http 层能力,这真的是大材小用。 All I need is just the value of that pseudo header field.我需要的只是那个伪 header 字段的值。
  2. Get the underlying tcp conn without hijacking it and read the frames from it.在不劫持的情况下获取底层 tcp conn 并从中读取帧。 -> 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).一种方法是在 http.Server.ConnState 中获取 tcp 连接(但我认为不能保证。我经常发现连接已关闭,无论如何我觉得它很麻烦)。

Is there a way, to just extract the pseudofield alone?有没有办法单独提取伪场?

the Host in http.Request does it in the sense that, it reads the:authority into r.Host field. http.Request 中的主机从某种意义上说,它将:权限读入 r.Host 字段。 But other fields are difficult to get a hold of.但其他领域很难掌握。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM