【问题标题】:Extracting Pyshark Header "Stream ID" Information from a HTTP/2 packet从 HTTP/2 数据包中提取 Pyshark 标头“流 ID”信息
【发布时间】:2020-10-29 22:36:59
【问题描述】:

假设在漂亮的打印之后,我的 http/2 数据包显示如下:

Layer HTTP2:
     Stream: HEADERS, Stream ID: 85, Length 169, POST xxxxxxxxxx
     Length: 169
     Type: HEADERS (1)
     Flags: 0x24
     .... ...0 = End Stream: False
     .... .1.. = End Headers: True
     .... 0... = Padded: False
     ..1. .... = Priority: True
     00.0 ..0. = Unused: 0x00
     0... .... .... .... .... .... .... .... = Reserved: 0x0
     .000 0000 0000 0000 0000 0000 0101 0101 = Stream Identifier: 85
     Pad Length: 0
     0... .... .... .... .... .... .... .... = Exclusive: False
     .000 0000 0000 0000 0000 0000 0000 1011 = Stream Dependency: 11
     Weight: 21
     Weight real: 22

等等等等。 我试图通过写下以下命令来提取“流 ID”:

print(cap[i].http2.stream['stream_ID'])

我尝试了上述方法,因为“流”字段对我来说就像字典的键值对。但它没有用。 您能帮我了解如何从上述代码中提取“Stream ID”的值吗? 附言“流”是“http2”数据包的字段名称,它给了我

Stream: HEADERS, Stream ID: 19, Length 30, POST xxxxxxx

当我应用命令时

print(cap[i].http2.stream)

【问题讨论】:

    标签: python python-3.x http2 pyshark


    【解决方案1】:

    尝试我在其他答案之一中描述的方法:

    Using Pyshark to pair key and value from JSON packet

    我能够使用这种方法从 JSON 和 HTTP 数据包层中提取键值对。也应该适用于 HTTP/2 数据包。抓包时可以设置'use_json=True'和'include_raw=False'。

    【讨论】:

      【解决方案2】:

      流 id 可通过 tcp 标签访问。即

      cap = ps.FileCapture(trace)
      for packet in cap:
          print(packet.tcp.stream)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-02-24
        • 2012-02-04
        • 2016-03-04
        • 1970-01-01
        • 2019-09-10
        • 2023-03-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多