Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda