diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs index e01b66df5..eb9c40c4f 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Bing.cs @@ -21,8 +21,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources try { const string api = "https://api.bing.com/qsonhs.aspx?q="; - - using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeDataString(query), token).ConfigureAwait(false); + + await using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeDataString(query), HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false); using var json = (await JsonDocument.ParseAsync(resultStream, cancellationToken: token)); var root = json.RootElement.GetProperty("AS"); @@ -31,16 +31,16 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources return new List(); return root.GetProperty("Results") - .EnumerateArray() - .SelectMany(r => r.GetProperty("Suggests") - .EnumerateArray() - .Select(s => s.GetProperty("Txt").GetString())) - .ToList(); + .EnumerateArray() + .SelectMany(r => r.GetProperty("Suggests") + .EnumerateArray() + .Select(s => s.GetProperty("Txt").GetString())) + .ToList(); } - catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException}) + catch (Exception e) when (e is HttpRequestException or { InnerException: TimeoutException }) { Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e); return null; @@ -49,7 +49,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources { Log.Exception("|Bing.Suggestions|can't parse suggestions", e); return new List(); - } + } } public override string ToString()