title: How exactly are timeouts handled by HttpClient?
body: <p>So there are two timeout properties that can be set on <a href="https://msdn.microsoft.com/en-us/library/system.net.http.httpclient(v=vs.118).aspx" rel="noreferrer">HttpClient</a>: <a href="https://msdn.microsoft.com/en-us/library/system.net.http.httpclient.timeout(v=vs.118).aspx" rel="noreferrer">HttpClient.TimeOut</a> and <a href="https://msdn.microsoft.com/en-us/library/system.net.http.webrequesthandler.readwritetimeout(v=vs.110).aspx" rel="noreferrer">WebRequestHandler.ReadWriteTimeout</a>.</p>
  
  <p>The first one is just a timeout for the whole request/response, so if a download/upload takes longer than that, I am out of luck and get cut off in the middle of transfer, no questions asked. This can obviously be overridden by setting the timeout to Infinite, but I am not certain what consequences does that have.</p>
  
  <p>Now the latter (ReadWriteTimeOut) - at least to my understanding - should be propagated all the way down to <a href="https://msdn.microsoft.com/en-us/library/system.net.sockets.networkstream(v=vs.110).aspx" rel="noreferrer">NetworkStream</a>, where it affects how long a request/response stream can block (be idle) until timeout.</p>
  
  <p>The HttpClient is using asynchronous versions of the <a href="https://msdn.microsoft.com/en-us/library/System.Net.HttpWebRequest(v=vs.100).aspx" rel="noreferrer">HttpWebRequest</a> methods, but as stated <a href="https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.begingetresponse(v=vs.100).aspx" rel="noreferrer">here</a>:</p>
  
  <blockquote>
    <p>In the case of asynchronous requests, it is the responsibility of the client application to implement its own time-out mechanism.</p>
  </blockquote>
  
  <p>It is not explained at all which time-out mechanism they have in mind (network stream idle timeout? timeout for the whole HTTP GET? etc...), so that makes me greatly confused.</p>
  
  <p>So my question is, how exactly does HttpClient handle network/protocol timeouts? I want to use HttpClient to upload/download potentially large files, so for that I set the HttpClient.TimeOut to infinite. But I am worried that by doing so, the app is at risk of waiting infinitely for some event that the server/network refuses to complete.</p>