Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does this code for checking proxy validity crash?
    primarykey
    data
    text
    <p>I have the following code in my program. When I try to check if the proxy is a valid proxy or not it crashes my program. Any ideas how to fix this? I'm using indy 10.</p> <pre><code>if checkproxy('http://www.google.com') label1.text:='Good' else label1.text:='bad'; </code></pre> <p>If I try to call another idHTTP connect after requesting checkproxy it crashes the program.</p> <p>This is the actual code.... That returns the error...</p> <p><pre><code> function TregForm.webSession(sURL : ansistring) : ansistring; var sstream : Tstringstream; httpcon : TIdHTTP; antifreeze : TIdAntiFreeze; begin result := ''; sstream := tstringstream.Create(''); try if length(SettingsForm.edtProxyServer.text) >= 7 then // 0.0.0.0 if checkproxy('<a href="http://www.google.com" rel="nofollow noreferrer">http://www.google.com</a>') then begin antifreeze := TIdAntiFreeze.Create(nil); httpcon := TIdHTTP.create; httpcon.ProxyParams.BasicAuthentication:=true; httpcon.ProxyParams.ProxyPassword:=SettingsForm.edtProxyPass.Text; httpcon.ProxyParams.ProxyPort:=strtoint(SettingsForm.edtProxyPort.Text); httpcon.ProxyParams.ProxyServer:=SettingsForm.edtProxyServer.Text; httpcon.ProxyParams.ProxyUsername:=SettingsForm.edtProxyUserName.Text; end else begin showmessage('Proxy Server Not Working.. Attempting to bypass the Proxy'); antifreeze := TIdAntiFreeze.Create(nil); httpcon := TIdHTTP.create; //httpcon.Request.ProxyConnection:=''; //httpcon.ProxyParams.BasicAuthentication:=false; //httpcon.ProxyParams.ProxyPassword:=''; //httpcon.ProxyParams.ProxyPort:=0; //httpcon.ProxyParams.ProxyServer:=''; //httpcon.ProxyParams.ProxyUsername:=''; end; httpcon.HandleRedirects := true; antifreeze.Active := true; HttpCon.Get(sURL,sstream); result := utf8towidestring(sstream.DataString); except httpcon.Disconnect; end; antifreeze.Active := false; freeandnil(httpcon); freeandnil(antifreeze); freeandnil(sstream); end;</p> <p>function TregForm.checkproxy(sURL : ansistring) : boolean; var //sstream : Tstringstream; httpcon : TIdHTTP; antifreeze : TIdAntiFreeze; begin result := true; try antifreeze := TIdAntiFreeze.Create(nil); httpcon := TIdHTTP.create; //sstream := tstringstream.Create(''); httpcon.ProxyParams.BasicAuthentication:=true; httpcon.ProxyParams.ProxyPassword:=SettingsForm.edtProxyPass.Text; httpcon.ProxyParams.ProxyPort:=strtoint(SettingsForm.edtProxyPort.Text); httpcon.ProxyParams.ProxyServer:=SettingsForm.edtProxyServer.Text; httpcon.ProxyParams.ProxyUsername:=SettingsForm.edtProxyUserName.Text;</p> <pre><code>httpcon.HandleRedirects := true; antifreeze.Active := true; HttpCon.Request.ProxyConnection:=SettingsForm.edtProxyServer.Text; HttpCon.head(sURL); httpCon.Disconnect; </code></pre> <p>except on E: EIdException do begin result:=false; end; On E:exception do begin //showmessage('External error:' + #13#10 + E.Message); showmessage('Proxy Settings Error'); result:=false; end; end; antifreeze.Active := false; freeandnil(httpcon); freeandnil(antifreeze); //freeandnil(sstream); end;</pre></code></p> <p>Error mesage: Exception AccessViolation in module key.exe at E001B844A. Access violation at address 005B844A in module 'key.exe'. Read of address 00000000.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload