delphi - Cannot get string from StringStream -


i sending http request google's map api, , fill stringstream response. however, when try read stream, presented empty string ''.

{ attempts json google's directions api } function getjsonstring_ordie(url : string) : string; var   lhttp: tidhttp;   ssl: tidssliohandlersocketopenssl;   buffer: tstringstream; begin   {sets ssl}   ssl := tidssliohandlersocketopenssl.create(nil);   {creates http request}   lhttp := tidhttp.create(nil);   {sets http request use ssl}   lhttp.iohandler := ssl;    {set buffer}   buffer := tstringstream.create(result);   {attempts json google's directions api}   lhttp.get(url, buffer);    result:= buffer.readstring(buffer.size); //an empty string put result         {frees http object}     lhttp.free;     {frees ssl object}     ssl.free;  end; 

why getting empty string back, when can see stringstream buffer has plenty of data (size of 32495 after called).

i've tested call, , returned valid json.

maybe first set buffer.position := 0?


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -