Skip to content

Commit ea37af5

Browse files
committed
further notes for EnsureSuccessStatusCode
1 parent 96ec3df commit ea37af5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

xml/System.Net.Http/HttpResponseMessage.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,10 @@ When the `disposing` parameter is `true`, this method releases all resources hel
352352
353353
## Remarks
354354
The <xref:System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode%2A> method throws an <xref:System.Net.Http.HttpRequestException> if <see cref="P:System.Net.Http.HttpResponseMessage.StatusCode" /> is outside of the range the range 200-299 (the range of status codes indicating success according to the standard).
355+
In some scenarios you may need stronger control defining which status codes are considered to be succesful; for example an API may be expected to always return `200 OK`.
356+
In such cases we recommend to manually check if <xref:System.Net.Http.HttpResponseMessage.StatusCode?displayProperty=nameWithType> matches the expected value(s).
355357
In .NET Framework and .NET Core 2.2 and earlier versions, if the <xref:System.Net.Http.HttpResponseMessage.Content%2A> is not `null`, this method will also call <xref:System.Net.Http.HttpResponseMessage.Dispose%2A> to free managed and unmanaged resources. Starting with .NET Core 3.0, the content will not be disposed.
356-
358+
357359
]]></format>
358360
</remarks>
359361
<exception cref="T:System.Net.Http.HttpRequestException">The HTTP response is unsuccessful.</exception>

0 commit comments

Comments
 (0)