Use proxy with WebViewGadget?
Posted: Tue Aug 06, 2024 12:38 am
Hi,
How to use a proxy with WebViewGadget?
Thanks in advance
How to use a proxy with WebViewGadget?
Thanks in advance
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Structure INTERNET_PROXY_INFO1
dwAccessType.l
lpszProxy.l
lpszProxyBypass.l
EndStructure
#INTERNET_OPTION_PROXY = 38
ProcedureDLL SetProxy1(Proxy.s, Port.l, flags.l=#INTERNET_OPEN_TYPE_PROXY) ; Set proxy for the current session
;/ Return 1 if success or 0 if fail
Protected ProxyServer.s = Proxy + ":" + Str(Port)
Protected PIInfo.INTERNET_PROXY_INFO1
PIInfo\dwAccessType = flags
PIInfo\lpszProxy = @ProxyServer
PIInfo\lpszProxyBypass = @""
If UrlMkSetSessionOption_(#INTERNET_OPTION_PROXY, @PIInfo, SizeOf(INTERNET_PROXY_INFO1), 0) = #S_OK
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Code: Select all
Procedure.i WebView2Gadget(Gadget.i, x.i, y.i, width.i, height.i, URL$, Window.i=#PB_Any, Proxy$="", ProxyBypass$="")
:
:
:
If Proxy$ = ""
Options$ + "--no-proxy-server "
Else
Options$ + "--proxy-server=" + #DQUOTE$ + Proxy$ + #DQUOTE$ + " "
EndIf
If ProxyBypass$ <> ""
Options$ + "--proxy-bypass-list=" + #DQUOTE$ + ProxyBypass$ + #DQUOTE$ + " "
EndIf
VebViewGadget is very nice, but is missing some basic funcionalities to be ready to use it in some real GUI.infratec wrote: Fri Aug 09, 2024 7:01 am In my WebView2Gadget() I do it like this:Code: Select all
Procedure.i WebView2Gadget(Gadget.i, x.i, y.i, width.i, height.i, URL$, Window.i=#PB_Any, Proxy$="", ProxyBypass$="") : : : If Proxy$ = "" Options$ + "--no-proxy-server " Else Options$ + "--proxy-server=" + #DQUOTE$ + Proxy$ + #DQUOTE$ + " " EndIf If ProxyBypass$ <> "" Options$ + "--proxy-bypass-list=" + #DQUOTE$ + ProxyBypass$ + #DQUOTE$ + " " EndIf
idle wrote: Fri Aug 09, 2024 2:30 am This might help assuming it's not node.js specific, see the 2nd code block down
maybe you can do that in the web gadget
https://arh.antoinevastel.com/nodejs/20 ... ncies.html
Could you elaborate?ricardo wrote: Fri Aug 09, 2024 7:14 amVebViewGadget is very nice, but is missing some basic funcionalities to be ready to use it in some real GUI.infratec wrote: Fri Aug 09, 2024 7:01 am In my WebView2Gadget() I do it like this:Code: Select all
Procedure.i WebView2Gadget(Gadget.i, x.i, y.i, width.i, height.i, URL$, Window.i=#PB_Any, Proxy$="", ProxyBypass$="") : : : If Proxy$ = "" Options$ + "--no-proxy-server " Else Options$ + "--proxy-server=" + #DQUOTE$ + Proxy$ + #DQUOTE$ + " " EndIf If ProxyBypass$ <> "" Options$ + "--proxy-bypass-list=" + #DQUOTE$ + ProxyBypass$ + #DQUOTE$ + " " EndIf
Code: Select all
WebView2AddBasicAuthenticationHandler()Code: Select all
Procedure.i WebView2GadgetBasicAuthenticationRequested(*this.WV2_EVENT_HANDLER, sender.ICoreWebView2, args.ICoreWebView2BasicAuthenticationRequestedEventArgs)
Protected Result.i
Protected *Gadget.WebView2Gadget_Structure
Protected *basicAuthenticationResponse.ICoreWebView2BasicAuthenticationResponse
Debug "WebView2GadgetBasicAuthenticationRequested with gadget: " + Str(*this\context)
Result = #S_FALSE
*Gadget = FindMapElement(WebView2GadgetMap(), Str(*this\context))
If *Gadget
args\get_Response(@*basicAuthenticationResponse)
*basicAuthenticationResponse\put_UserName(#WebProxyUser)
*basicAuthenticationResponse\put_Password(#WebProxyPassword)
Result = #S_OK
EndIf
ProcedureReturn Result
EndProcedure
No, i want to do for Windows only.idle wrote: Sun Aug 11, 2024 1:23 am If you wanted to do that cross platform wouldn't use http request with CONNECT or via curl since flag is missing in httprequest.
Im trying to understand what the question is as there are numerous kinds of proxy. So does this handle https transparent proxy?