-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Support to request extensions://** by HttpClient #52836
Comments
@newbe36524 thanks for contacting us. This is a question for the dotnet/runtime folks |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsIs your feature request related to a problem? Please describe.When I try to develop a browser extension by blazor. I have to fetch some resources hosts in extensions://* protocol by HttpClient. But it throw a exception like: blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Only 'http', 'https', and 'blob' schemes are allowed. (Parameter 'requestUri')
System.ArgumentException: Only 'http', 'https', and 'blob' schemes are allowed. (Parameter 'requestUri')
at System.Net.Http.HttpRequestMessage.InitializeValues(HttpMethod method, Uri requestUri)
at System.Net.Http.HttpRequestMessage..ctor(HttpMethod method, Uri requestUri)
at System.Net.Http.HttpClient.CreateRequestMessage(HttpMethod method, Uri uri)
at System.Net.Http.HttpClient.GetStreamAsync(Uri requestUri, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.GetStreamAsync(Uri requestUri)
at System.Net.Http.HttpClient.GetStreamAsync(String requestUri)
at Newbe.Blazors.TryNet.Pages.Index.Compile(String text, MetadataReference[] additionalReferences) in D:\Repo\newbe\Newbe.Demo\src\BlogDemos\Newbe.Blazor\Newbe.Blazors.TryNet\Newbe.Blazors.TryNet\Pages\Index.cs:line 64
at Newbe.Blazors.TryNet.Pages.Index.CompileAndEncode(String text, MetadataReference[] additionalReferences) in D:\Repo\newbe\Newbe.Demo\src\BlogDemos\Newbe.Blazor\Newbe.Blazors.TryNet\Newbe.Blazors.TryNet\Pages\Index.cs:line 49
at Newbe.Blazors.TryNet.Pages.Index.OnClickRunAsync() in D:\Repo\newbe\Newbe.Demo\src\BlogDemos\Newbe.Blazor\Newbe.Blazors.TryNet\Newbe.Blazors.TryNet\Pages\Index.cs:line 86
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle) Describe the solution you'd likeA clear and concise description of what you want to happen. Include any alternative solutions you've considered. Please allow some additional schema like 'extensions' by some Property in HttpClient class.
|
@newbe36524 what is "extensions://* protocol"? I never heard of that. What does it do? What's the protocol? As the exception says, |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsIs your feature request related to a problem? Please describe.When I try to develop a browser extension by blazor. I have to fetch some resources hosts in extensions://* protocol by HttpClient. But it throw a exception like: blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Only 'http', 'https', and 'blob' schemes are allowed. (Parameter 'requestUri')
System.ArgumentException: Only 'http', 'https', and 'blob' schemes are allowed. (Parameter 'requestUri')
at System.Net.Http.HttpRequestMessage.InitializeValues(HttpMethod method, Uri requestUri)
at System.Net.Http.HttpRequestMessage..ctor(HttpMethod method, Uri requestUri)
at System.Net.Http.HttpClient.CreateRequestMessage(HttpMethod method, Uri uri)
at System.Net.Http.HttpClient.GetStreamAsync(Uri requestUri, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.GetStreamAsync(Uri requestUri)
at System.Net.Http.HttpClient.GetStreamAsync(String requestUri)
at Newbe.Blazors.TryNet.Pages.Index.Compile(String text, MetadataReference[] additionalReferences) in D:\Repo\newbe\Newbe.Demo\src\BlogDemos\Newbe.Blazor\Newbe.Blazors.TryNet\Newbe.Blazors.TryNet\Pages\Index.cs:line 64
at Newbe.Blazors.TryNet.Pages.Index.CompileAndEncode(String text, MetadataReference[] additionalReferences) in D:\Repo\newbe\Newbe.Demo\src\BlogDemos\Newbe.Blazor\Newbe.Blazors.TryNet\Newbe.Blazors.TryNet\Pages\Index.cs:line 49
at Newbe.Blazors.TryNet.Pages.Index.OnClickRunAsync() in D:\Repo\newbe\Newbe.Demo\src\BlogDemos\Newbe.Blazor\Newbe.Blazors.TryNet\Newbe.Blazors.TryNet\Pages\Index.cs:line 86
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle) Describe the solution you'd likeA clear and concise description of what you want to happen. Include any alternative solutions you've considered. Please allow some additional schema like 'extensions' by some Property in HttpClient class.
|
I can develop a chrome extension by Blazor WebAssembly. just like this project https://github.com/newbe36524/Amazing-Favorites. In this way, I can using C# to build a chrome extensions. However, if I want to request a resource such as extension://gglgheekopdecoeeinlggdmedamjbjpj/sample.json by HttpClient. The exception raised |
Actually, I try to port a Blazor WebAssembly project from hosted style into to chrome extension style. But block by if I want to send a request with extensions://* protocol since all files is host in extensions folder instead of a web server. https://github.com/BlazorRepl/BlazorRepl/blob/master/Core/CompilationService.cs#L233 |
It is still not clear to me what is the "extensions://*" protocol? Is it just HTTP? Or something else? That will answer the question if it is something |
The extensions://* is chrome or the chromium system's private "extends manager protocol" You can think that is chromium's private file protocol, like file:\..... |
It seems inappropriate for generic framework like .NET HttpClient to worry about other product private guts. It seems like some kind of external package would be much more appropriate. |
@wfurt In fact now, I am limited by this line of code because its requirements must be within the given range.
I'm curious if it's possible to change this behavior by way of dependency injection or other options to be able to support wider or narrower scopes, rather than using this hard-coded approach. |
@newbe36524 I believe that is only checked if you set CC @marek-safar @kjpou1 @lewing we should consider if it makes sense to explicitly support things like this for browser. |
The check is also in |
If this boils down to schema check only, I think we could loosen the restriction for wasm. |
@scalablecory Yeah, just as @MihaZupan mentioned, for now, it block me in HttpClient.BaseUri and HttpRequestMessage.Uri, and even WebRequest.Create. |
Yeah, I'm not sure what the point of checking this in HttpClient/HttpRequestMessage themselves is. The underlying HttpClientHandler will enforce whatever schemes it knows how to handle. Limiting this at the HttpClient/HttpRequestMessage layer seems unnecessary. |
Triage: We agree that |
@stephentoub what do you think? |
Hi, friends, any update? I wonder that would it be ok in next net 6 preview or not? |
AFIK It is too late for preview 6 @newbe36524. We agreed this may make sense but it is not on top of the priority list. |
Would a pull request be accepted? |
Yes, we would take a PR. @stephentoub do you have opinion on the plan? |
As long as all of our handlers do the appropriate validation for what they're capable of, removing such validation from HttpClient / HttpRequestMessage sounds like the right thing to do. |
Is your feature request related to a problem? Please describe.
When I try to develop a browser extension by blazor. I have to fetch some resources hosts in extensions://* protocol by HttpClient.
But it throw a exception like:
Describe the solution you'd like
A clear and concise description of what you want to happen. Include any alternative solutions you've considered.
Please allow some additional schema like 'extensions' by some Property in HttpClient class.
The text was updated successfully, but these errors were encountered: