-
Notifications
You must be signed in to change notification settings - Fork 50
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
Proxy requests and round trip JavaScript invocations #43
Conversation
Added support in Windows and Android for proxying web requests from the browser through native code to allow for modifying the request, and creating custom responses.
Add proxy support for iOS and Mac. Cleaned up some of the previous proxy code for Android and Windows.
Add round trip invoke JS-.NET-JS by leveraging the proxy framework that was created.
- Bug fix: expose method to get proxy origin in JS. iOS/Mac has a different URL scheme than Android/Windows. Simple helper method gives users JS code the correct URL to the proxy service for the platform the web view is running on. - A few improvements to better handle errors. - Document code - Readme documentation - Move async invoke samples to methodinvoke.html sample
I'm still very patiently waiting for this to be approved. lol @Eilon p.s. after the merge conflicts are resolved. There weren't any 2 weeks ago when it was submitted. |
Looking at this now... this is very cool! |
Here are my initial notes, and I pushed a change to the PR that addresses some of my comments:
@rbrundritt thank you so much for this PR! This looks fantastically cool and seem to work great! Please let me know if you have any thoughts on my comments so far. You can see just my update if you look at this commit: 69ede5a |
The picture in pictures.zip I grabbed from wikimedia. I don't recall any attributions being required (main reason I grabbed a random image from there). Like your improvements. Let me know if you have any questions on my code. |
Thank you again @rbrundritt . I just pushed another small change and have this further though on the Proxy code itself (especially pertaining to the Async
Regarding the totally of my comments, I'll get started working on addressing all of these. I think most of my proposed changes don't affect anything publicly visible. The two things that would affect publicly visible behavior:
|
Alright, I tested everything on iOS (Simulator) and MacCat and I good news / bad news / medium news:
So I think after an additional quick review I'll still merge it in, and we'll track the follow-up items in a separate issue: #51 |
commit 6bb1c5f Author: Eilon Lipton <[email protected]> Date: Mon Mar 11 11:53:17 2024 -0700 Update HybridWebViewHandler.MacCatalyst.cs commit 3b56ebe Author: Eilon Lipton <[email protected]> Date: Mon Mar 11 11:43:19 2024 -0700 Try to make iOS proxy code async
It turns out this was easier to fix than I thought! All I had to do was simply make the code async! And the call to Here's the async call (without And the original (unchanged) So now it all works great on iOS and MacCat! I'll leave #51 open because I want to check how to fix Android as well because it's still using |
And I logged #52 for some of the other follow-up tasks. |
This pull request is in relation to #42
All existing capabilities and API interface continue to work the same as before. This is an additive pull request.
New features this pull request adds:
InvokeJsMethodAsync
). You can now call a .NET method from JavaScript (with or without parameters) and get a response back from .NET to the calling JavaScript function. This is an async feature since you have to wait for the response. Due to WebView limitations of some platforms, input data is passed as an encoded query string parameter. This will likely mean there is a size limit on input data from the JavaScript side. The result is passed as a JSON stream in the response body, so that should allow massive amounts of data to be sent from .NET to JavaScript if needed.All code has been documented, and the Readme updated accordingly.