delphi - Updated to Indy 130 packages from 120 and now this code does not work -


so used work without hitch "socket error #10054 connection reset peer."

i assume started happening once updated indy packages. today first time running code since then.

can explain how update might have changed behavior of code , how resolve it?

thank you

function postdata(url : string; param: tstringlist) : string; var   text: string;   shttpsocket: tidhttp;   sshsockethandler: tidssliohandlersocketopenssl;   resstream: tstringstream; begin   shttpsocket := tidhttp.create;   sshsockethandler := tidssliohandlersocketopenssl.create;   shttpsocket.iohandler := sshsockethandler;   shttpsocket.request.contenttype := 'application/x-www-form-urlencoded';   shttpsocket.request.method := 'post';   resstream := tstringstream.create;    shttpsocket.post(url, param, resstream);   resstream.seek(0, sofrombeginning);   text := resstream.datastring;   result := text; end; 

if posting https url, make sure tidssliohandlersocketopenssl configured server trying connect to. chances are, defaults might not matching server expecting. in particular, tidssliohandlersocketopenssl.method , tidssliohandlersocketopenssl.sslversions properties default tlsv1, maybe server not support tlsv1.

on side note, tstringstream operates differently in d2009+ did in earlier versions, suggest avoid , let indy decode text you:

function postdata(const url : string; params: tstrings) : string;  var    shttpsocket: tidhttp;    sshsockethandler: tidssliohandlersocketopenssl;  begin    shttpsocket := tidhttp.create;    try     sshsockethandler := tidssliohandlersocketopenssl.create(shttpsocket);      // configure sshsockethandler needed...     // perhaps try @ minimum:     // sshsockethandler.ssloptions.method := sslvsslv23;     shttpsocket.iohandler := sshsockethandler;      result := shttpsocket.post(url, params);        shttpsocket.free;   end; end;  

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -