Class HttpUtils
Provides the reading of an HTTP response's header off a stream, as a client reads its server's.
public static class HttpUtils
- Inheritance
-
HttpUtils
- Inherited Members
Methods
ReadResponse(Stream, CancellationToken, int)
Reads an HTTP response's header off a stream: its status and headers, with no body.
public static Task<HttpResponseMessage> ReadResponse(Stream stream, CancellationToken cancellationToken, int maxLength = 131072)
Parameters
streamStreamThe stream.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
maxLengthintThe longest header it takes, in bytes. The default is 128 KB.
Returns
- Task<HttpResponseMessage>
A task whose result is the response.
Exceptions
- Exception
The stream ended, before the header or inside it; the header is longer than allowed; or it is not an HTTP response's.
- FormatException
The status code is not a number.
- OverflowException
The status code is out of an integer's range.
- OperationCanceledException
cancellationTokenwas canceled.