QNetworkReply - 连接建立、第一个字节写入等
我想记录 QNetworkReply 对象的生命周期。这包括:
- 当底层套接字连接建立时
- 当发送请求的第一个字节
- 时 当收到响应的第一个字节
- 时 当响应的最后一个字节完成时
(3) 和 (4) 可以通过监听 downloadProgress 来确定信号,但我不知道该怎么做(1)和(2)。有没有办法监听 QNetworkReply 的底层套接字? GET 请求似乎不会触发 uploadprogress 信号。
I'd like to log the lifetime of a QNetworkReply object. This includes:
- When the underlying socket connection is established
- When the first byte of the request is sent
- When the first byte of the response received
- When the last byte of the response finished
(3) and (4) can be determined by listening for the downloadProgress signal, but I'm not sure how to do (1) and (2). Is there a way to listen on the underlying socket of a QNetworkReply? The uploadprogress signal doesn't seem to be triggered for GET requests.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道(1)是否可能,但其他都很简单。您看过我的网络跟踪示例吗?它不适合您的情况吗?
I have no idea if (1) is possible but the others are easy. Have you seen my network trace example? Does it not work for your case?
据我所知,Qt 没有公开 QNetworkAccessManager 用于获取数据的机制,因此我认为您无法完成列表中的第一个任务或第二个任务。
请记住,
QNetworkAccessManager
不仅处理http(s):
方案,还处理本地方案,例如file:
和qrc:
> 不需要任何套接字连接。As far as I know Qt does not expose mechanism used by
QNetworkAccessManager
to get data so I think you can't accomplish neither the first nor the second task from your list.Please remember that
QNetworkAccessManager
handles not onlyhttp(s):
schemes but also local ones likefile:
andqrc:
which do not require any socket connection.