ResponseStream re-read after read timeout

520 views Asked by At

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.

2

There are 2 answers

0
Thomas Levesque On BEST ANSWER

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

0
BalusC On

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.