Skip to content

Commit 776ec62

Browse files
author
FERNAN OVIEDO CANDELARESI
committed
Add EnsureStatusCode invokation to illustrate the point of the ResponseHeadersRead option
1 parent dcca94f commit 776ec62

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xml/System.Net.Http/HttpCompletionOption.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ httpClient.Timeout = TimeSpan.FromSeconds(30);
4848
using (var response = await httpClient.GetAsync("http://localhost:12345/", HttpCompletionOption.ResponseHeadersRead)) // 30-second timeout but ONLY up until past the headers
4949
{
5050
// Do other stuff that doesn't rely on the content first, like status code validation
51-
// ...
51+
response.EnsureSuccessStatusCode();
5252
5353
var content = await response.Content.ReadAsStringAsync(); // NO TIMEOUT
5454
}

0 commit comments

Comments
 (0)