Skip to content

Commit a0c4cc3

Browse files
committed
use ParseAsync in Google
1 parent 7bbd8c6 commit a0c4cc3

File tree

1 file changed

+5
-4
lines changed
  • Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources

1 file changed

+5
-4
lines changed

Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources/Google.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@
77
using Flow.Launcher.Infrastructure.Logger;
88
using System.Net.Http;
99
using System.Text.Json;
10+
using System.IO;
1011

1112
namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
1213
{
1314
public class Google : SuggestionSource
1415
{
1516
public override async Task<List<string>> Suggestions(string query)
1617
{
17-
string result;
18+
Stream resultStream;
1819
try
1920
{
2021
const string api = "https://www.google.com/complete/search?output=chrome&q=";
21-
result = await Http.GetAsync(api + Uri.EscapeUriString(query)).ConfigureAwait(false);
22+
resultStream = await Http.GetStreamAsync(api + Uri.EscapeUriString(query)).ConfigureAwait(false);
2223
}
2324
catch (HttpRequestException e)
2425
{
2526
Log.Exception("|Google.Suggestions|Can't get suggestion from google", e);
2627
return new List<string>();
2728
}
28-
if (string.IsNullOrEmpty(result)) return new List<string>();
29+
if (resultStream.Length == 0) return new List<string>();
2930
JsonDocument json;
3031
try
3132
{
32-
json = JsonDocument.Parse(result);
33+
json = await JsonDocument.ParseAsync(resultStream);
3334
}
3435
catch (JsonException e)
3536
{

0 commit comments

Comments
 (0)