Re: about server push in indy9

Giganews Newsgroups
Subject: Re: about server push in indy9
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Mon, 17 Oct 2005

"pengpzy" <pe…@qcet.cn> wrote in message
news:CBDD85B143DEE240pe…@qcet.cn...

> I want to do this in bcb6 with indy9; but after I post to the server,I can
> not get any answer when the TidHTTP is connected, and when the server
> close the connect,I get the answer. why?

Because your code is completely wrong.

> if(!IdHTTP2->Connected()) IdHTTP2->Connect(20);

Get rid of that entirely.

> IdHTTP2->Post("/xmlBlaster/AppletServlet",TempList2) ;

You must specify a complete URL, not just a path alone.

> IdHTTP2->IOHandler->Recv(buff,100);//
> AnsiString tmpline=AnsiString(buff);  Memo1->Lines->Add(tmpline);

That is wrong.  Post() already received, and returned, all of the response
data.  Calling Recv() afterwards will hang waiting for data that never
arrives.

Use this code instead:

    TStringList *Headers = new TStringList;
    TStringList *PostData = new TStringList;
    TStringList ResponseData = new TStringList;

    // fill Headers and PostData as needed...

    IdHTTP2->Request->CustomHeaders->AddStdValues(Headers);
    IdHTTP2->Post(http://www.site.com/xmlBlaster/AppletServlet", PostData,
ResponseData);

    Memo1->Lines->Add(IdHTTP2->Response->RawHeaders);
    Memo1->Lines->Add();
    Memo1->Lines->Add(ResponseData);

    delete Headers;
    delete PostData;
    delete ResponseData;

Gambit

Replies

In response to

about server push in indy9 posted by pengpzy on Mon, 17 Oct 2005