Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
Timeout when using HttpCompletionOption.ResponseHeadersRead?

Wondering if anyone could help me in understanding timeouts when HttpCompletionOption.ResponseHeadersRead is used. Given the code below:

using (HttpClient client = new HttpClient())
{
    client.Timeout = TimeSpan.FromSeconds(5);
    const string url = "https://url";
    using (HttpResponseMessage response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead))
    using (Stream stream = await response.Content.ReadAsStreamAsync())
    {
        ... do some processing on stream ...
    }
}

Is my understanding correct that:

  • the timeout of the client.GetAsync call is 5s (because of client.Timeout = TimeSpan.FromSeconds(5))? and because HttpCompletionOption.ResponseHeadersRead is used, client.GetAsync is successfully completed once the headers are downloaded
  • the stream processing is not affected by the client.Timeout = TimeSpan.FromSeconds(5) configuration
  • stream processing does not have a timeout / time limit (on the client side at least). so even for a very large file (say 1GB), it would theoretically be ok for the stream processing to take many minutes

Thanks.

Sorry, one other related question, say the stream processing consisted of a CopyTo call:

await stream.CopyToAsync(destStream);

Does the default CopyToAsync call above (no cancellation token) have any sort of time restriction?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!