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.
精彩评论