File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Plugins/Flow.Launcher.Plugin.WebSearch/SuggestionSources Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 7
7
using Flow . Launcher . Infrastructure . Logger ;
8
8
using System . Net . Http ;
9
9
using System . Text . Json ;
10
+ using System . IO ;
10
11
11
12
namespace Flow . Launcher . Plugin . WebSearch . SuggestionSources
12
13
{
13
14
public class Google : SuggestionSource
14
15
{
15
16
public override async Task < List < string > > Suggestions ( string query )
16
17
{
17
- string result ;
18
+ Stream resultStream ;
18
19
try
19
20
{
20
21
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 ) ;
22
23
}
23
24
catch ( HttpRequestException e )
24
25
{
25
26
Log . Exception ( "|Google.Suggestions|Can't get suggestion from google" , e ) ;
26
27
return new List < string > ( ) ;
27
28
}
28
- if ( string . IsNullOrEmpty ( result ) ) return new List < string > ( ) ;
29
+ if ( resultStream . Length == 0 ) return new List < string > ( ) ;
29
30
JsonDocument json ;
30
31
try
31
32
{
32
- json = JsonDocument . Parse ( result ) ;
33
+ json = await JsonDocument . ParseAsync ( resultStream ) ;
33
34
}
34
35
catch ( JsonException e )
35
36
{
You can’t perform that action at this time.
0 commit comments