diff options
| author | Bond_009 <bond.009@outlook.com> | 2021-09-21 22:32:14 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2021-09-21 22:32:14 +0200 |
| commit | ec45808275c6d253ca4384cf7992475eed843452 (patch) | |
| tree | 965e1874480d6dcb0dda80c224e3d54656725f1f /Emby.Dlna | |
| parent | b4c05180017edd9067d5df5e26a382410125fd60 (diff) | |
SsdpHttpClient: Ensure successful status code before reading response
Diffstat (limited to 'Emby.Dlna')
| -rw-r--r-- | Emby.Dlna/PlayTo/SsdpHttpClient.cs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Emby.Dlna/PlayTo/SsdpHttpClient.cs b/Emby.Dlna/PlayTo/SsdpHttpClient.cs index f14f73bb6..4b92fbff4 100644 --- a/Emby.Dlna/PlayTo/SsdpHttpClient.cs +++ b/Emby.Dlna/PlayTo/SsdpHttpClient.cs @@ -45,10 +45,12 @@ namespace Emby.Dlna.PlayTo header, cancellationToken) .ConfigureAwait(false); + response.EnsureSuccessStatusCode(); + await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); return await XDocument.LoadAsync( stream, - LoadOptions.PreserveWhitespace, + LoadOptions.None, cancellationToken).ConfigureAwait(false); } @@ -86,6 +88,7 @@ namespace Emby.Dlna.PlayTo using var response = await _httpClientFactory.CreateClient(NamedClient.Default) .SendAsync(options, HttpCompletionOption.ResponseHeadersRead) .ConfigureAwait(false); + response.EnsureSuccessStatusCode(); } public async Task<XDocument> GetDataAsync(string url, CancellationToken cancellationToken) @@ -94,12 +97,13 @@ namespace Emby.Dlna.PlayTo options.Headers.UserAgent.ParseAdd(USERAGENT); options.Headers.TryAddWithoutValidation("FriendlyName.DLNA.ORG", FriendlyName); using var response = await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(options, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + response.EnsureSuccessStatusCode(); await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); try { return await XDocument.LoadAsync( stream, - LoadOptions.PreserveWhitespace, + LoadOptions.None, cancellationToken).ConfigureAwait(false); } catch |
