-
-
Notifications
You must be signed in to change notification settings - Fork 455
Allow plugins to use web URL's for icon paths #1351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ffbd8fd
03e319e
fda155a
b5c2125
d62d710
301882d
5c33b0d
b7900b2
57d63cf
ed107cc
7f1b9d0
416c44f
ec1a061
ebd6f17
eb3f723
ef575bb
3708489
191c6af
957c4e2
eb5e33a
c39a727
99fd8d1
2507d1a
ba0aee1
cae0b7b
e9bf62e
0fd127a
cf9dd4a
ffa40b0
ff2ebc8
e86a2f1
28256a7
101593a
169857b
26668b4
ce52919
414e55c
622b130
e5948a7
67443fd
3665bd9
83ec809
303d3b9
fb3a23f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,7 @@ public static void UpdateProxy(ProxyProperty property) | |
| var userName when string.IsNullOrEmpty(userName) => | ||
| (new Uri($"http://{Proxy.Server}:{Proxy.Port}"), null), | ||
| _ => (new Uri($"http://{Proxy.Server}:{Proxy.Port}"), | ||
| new NetworkCredential(Proxy.UserName, Proxy.Password)) | ||
| new NetworkCredential(Proxy.UserName, Proxy.Password)) | ||
| }, | ||
| _ => (null, null) | ||
| }, | ||
|
|
@@ -79,7 +79,7 @@ var userName when string.IsNullOrEmpty(userName) => | |
| _ => throw new ArgumentOutOfRangeException() | ||
| }; | ||
| } | ||
| catch(UriFormatException e) | ||
| catch (UriFormatException e) | ||
| { | ||
| API.ShowMsg("Please try again", "Unable to parse Http Proxy"); | ||
| Log.Exception("Flow.Launcher.Infrastructure.Http", "Unable to parse Uri", e); | ||
|
|
@@ -94,7 +94,7 @@ public static async Task DownloadAsync([NotNull] string url, [NotNull] string fi | |
| if (response.StatusCode == HttpStatusCode.OK) | ||
| { | ||
| await using var fileStream = new FileStream(filePath, FileMode.CreateNew); | ||
| await response.Content.CopyToAsync(fileStream); | ||
| await response.Content.CopyToAsync(fileStream, token); | ||
| } | ||
| else | ||
| { | ||
|
|
@@ -117,7 +117,7 @@ public static async Task DownloadAsync([NotNull] string url, [NotNull] string fi | |
| public static Task<string> GetAsync([NotNull] string url, CancellationToken token = default) | ||
| { | ||
| Log.Debug($"|Http.Get|Url <{url}>"); | ||
| return GetAsync(new Uri(url.Replace("#", "%23")), token); | ||
| return GetAsync(new Uri(url), token); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change intended?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah I don't think that's needed since it is creating a url.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do you mean? the old code is also creating a url too no? |
||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -130,36 +130,57 @@ public static async Task<string> GetAsync([NotNull] Uri url, CancellationToken t | |
| { | ||
| Log.Debug($"|Http.Get|Url <{url}>"); | ||
| using var response = await client.GetAsync(url, token); | ||
| var content = await response.Content.ReadAsStringAsync(); | ||
| if (response.StatusCode == HttpStatusCode.OK) | ||
| { | ||
| return content; | ||
| } | ||
| else | ||
| var content = await response.Content.ReadAsStringAsync(token); | ||
| if (response.StatusCode != HttpStatusCode.OK) | ||
| { | ||
| throw new HttpRequestException( | ||
| $"Error code <{response.StatusCode}> with content <{content}> returned from <{url}>"); | ||
| } | ||
|
|
||
| return content; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Asynchrously get the result as stream from url. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I revised some of the |
||
| /// Send a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation. | ||
| /// </summary> | ||
| /// <param name="url">The Uri the request is sent to.</param> | ||
| /// <param name="completionOption">An HTTP completion option value that indicates when the operation should be considered completed.</param> | ||
| /// <param name="token">A cancellation token that can be used by other objects or threads to receive notice of cancellation</param> | ||
| /// <returns></returns> | ||
| public static Task<Stream> GetStreamAsync([NotNull] string url, | ||
| CancellationToken token = default) => GetStreamAsync(new Uri(url), token); | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// Send a GET request to the specified Uri with an HTTP completion option and a cancellation token as an asynchronous operation. | ||
| /// </summary> | ||
| /// <param name="url"></param> | ||
| /// <param name="token"></param> | ||
| /// <returns></returns> | ||
| public static async Task<Stream> GetStreamAsync([NotNull] string url, CancellationToken token = default) | ||
| public static async Task<Stream> GetStreamAsync([NotNull] Uri url, | ||
| CancellationToken token = default) | ||
| { | ||
| Log.Debug($"|Http.Get|Url <{url}>"); | ||
| return await client.GetStreamAsync(url, token); | ||
| } | ||
|
|
||
| public static async Task<HttpResponseMessage> GetResponseAsync(string url, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, | ||
| CancellationToken token = default) | ||
| => await GetResponseAsync(new Uri(url), completionOption, token); | ||
|
|
||
| public static async Task<HttpResponseMessage> GetResponseAsync([NotNull] Uri url, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, | ||
| CancellationToken token = default) | ||
| { | ||
| Log.Debug($"|Http.Get|Url <{url}>"); | ||
| var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead, token); | ||
| return await response.Content.ReadAsStreamAsync(); | ||
| return await client.GetAsync(url, completionOption, token); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Asynchrously send an HTTP request. | ||
| /// </summary> | ||
| public static async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken token = default) | ||
| public static async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, CancellationToken token = default) | ||
| { | ||
| return await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token); | ||
| return await client.SendAsync(request, completionOption, token); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.