读取超时后重新读取ResponseStream
我想知道当我读取响应流并发生超时时,我可以重试读取吗?或者我必须提出新的要求吗?我正在下载的服务器不支持恢复,因此我需要防止超时。
I am wondering when I read a response stream and a timeout occurs, can I retry the read? Or do I have to make a new request? The server that I am downloading from does not support resuming, so I need to protect against timeouts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,你不能重试。您需要重新发出请求
No, you can't retry. You need to reissue the request
你怎么知道服务器不接受简历?是
Accept-Ranges
响应中确实缺少标头?如果没有,您可以使用Range 恢复请求
标头。如果服务器确实不支持它,那么您可以尝试的最好方法是使用
Connection: keep-alive
标头结合保持活动< /code>
标头,您可以在其中指定超时。
希望这有帮助。
How do you know that the server doesn't accept resumes? Is the
Accept-Ranges
header indeed lacking in the response? If not, you could resume the request using theRange
header.If the server indeed doesn't support it, then best what you can try is to inform the server that you want to keep the connection alive using
Connection: keep-alive
header in combination with theKeep-Alive
header wherein you can specify the timeout.Hope this helps.