Re: HTTP Response ContentStream not delivering anything

Giganews Newsgroups
Subject: Re: HTTP Response ContentStream not delivering anything
Posted by:  Remy Lebeau \(Indy Team\) (no.spam@no.spam.com)
Date: Mon, 10 Mar 2008

"Richard A. DeVenezia" <rdevenez…@wildblue.net> wrote in message
news:621629766F4BE340rdevenez…@wildblue.net...

> Afer posting I am trying to use
>  HTTP.Response.ContentStream

That is the wrong way to use TIdHTTP.  If you want data to be loaded into a
TStream, you must pass your own TStream to Post()'s AResponseContent
parameter instead, ie:

    var
        Strm: TStringStream;
    begin
        Strm := TMemoryStream.Create;
        try
            HTTP.Post(URL, postdata, Strm);
            // use Strm as needed...
        finally
            Strm.Free;
        end;
    end;

Alternatively, use a String instead:

    var
        XML: String;
    begin
        XML := HTTP.Post(URL, postdata);
        // use XML as needed...
    end;

> but the .size is zero

Of course, because you did not pass your own TStream to Post() to begin
with.  The Response.ContentStream property is for internal use only.

> I'm pretty sure the server is responding properly.

Perhaps, but you are not receiving the response correctly.

Gambit

Replies

In response to

HTTP Response ContentStream not delivering anything posted by Richard A. DeVenezia on Sat, 8 Mar 2008