开发者

ResponseStream re-read after read timeout

开发者 https://www.devze.com 2022-12-11 07:10 出处:网络
I am wondering when I read a response stream and a timeout occurs, can I retry the read? 开发者_Go百科 Or do I have to make a new request?The server that I am downloading from does not support resumin

I am wondering when I read a response stream and a timeout occurs, can I retry the read? 开发者_Go百科 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.


No, you can't retry. You need to reissue the request


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 the Range 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 the Keep-Alive header wherein you can specify the timeout.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消