用python3.5hyperlibrary实现HTTP/2客户端

2024-06-16 12:56:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用python3.5hyperlibrary实现我自己的HTTP/2客户端。在我请求大于64Kb的对象之前,一切似乎都很正常。在

我已经将network_buffer_size设置为比默认值更大的值(实际上是64K),甚至设置库代码以将网络缓冲区的大小设置得足够大,以便它可以处理响应,但不管文件有多大,从服务器接收的数据量仍然是64K。在

conn = hyper.HTTP20Connection(SERVER, int(sys.argv[2]), True, window_manager=FlowControlManagerUs, enable_push=False, ssl_context=ssl_context)
conn.network_buffer_size = 256000
conn.connect()

我的请求是这样的:

^{pr2}$

我实现了FlowControlManager,只是将初始窗口大小设置为大值。在


Tags: 文件对象代码网络服务器http客户端ssl
1条回答
网友
1楼 · 发布于 2024-06-16 12:56:50

HTTP/2中的流控制是通过两种类型的流控制窗口实现的:一种用于连接,另一种用于每个流,用RFC 7540, 5.2 Flow control来表示:

A flow-control scheme ensures that streams on the same connection do not destructively interfere with each other. Flow control is used for both individual streams and for the connection as a whole.

hyper允许通过对hyper.http20.window.BaseFlowControlManager进行子分类来实现您自己的流控制策略。通过将initial_window_size设置为大值,您已经将连接窗口设置为一个大值。但是流窗口保持不变,结果流窗口的默认值是64kb,来自第5.2.1 Flow-Control Principles

  1. The initial value for the flow-control window is 65,535 octets for both new streams and the overall connection.

为了增加流的窗口,还必须实现流控制管理器的increase_window_size方法。在

相关问题 更多 >