Yes indeed. I added a LocationChange event handler to your source: void __fastcall THttpTestForm::HttpCli1LocationChange(TObject *Sender) { DisplayMemo->Lines->Add("LocationChange StatusCode = " + IntToStr(HttpCli1->StatusCode)); }
I also added the line: DisplayMemo->Lines->Add("RequestDone StatusCode = " + IntToStr(HttpCli1->StatusCode)); to your RequestDone event handler. I set breakpoints in both to see how many times they were invoked. Results: 2 LocationChanges, StatusCodes 302 and 0, then 2 RequestDones, StatusCode 0 and 200. The only way to know that a RequestDone is the final one and no other ones will foloow in this case is to test the StatusCode and return when it is 0. If the client gets deleted after the firts RequestDone, the second one generates an AV. I use C++Builder 6 btw. Output below: cmd> GET / HTTP/1.0 cmd> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* cmd> User-Agent: Mozilla/3.0 (compatible) cmd> Host: help.lycos.com cmd> text/html => document.htm Document = document.htm LocationChange StatusCode = 302 LocationChange StatusCode = 0 RequestDone Error = 0 RequestDone StatusCode = 0 cmd> GET /network_1_help.asp HTTP/1.0 cmd> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* cmd> User-Agent: Mozilla/3.0 (compatible) cmd> Host: help.lycos.com cmd> text/html => network_1_help.asp Document = network_1_help.asp RequestDone Error = 0 RequestDone StatusCode = 200 StatusCode = 200 hdr>HTTP/1.1 200 OK hdr>Server: Microsoft-IIS/5.0 hdr>Date: Sun, 24 Jul 2005 13:40:32 GMT hdr>P3P: CP="CAO DSP COR CURa ADMa DEVa CONo PSAa OUR IND DEM PRE PUR TAIa NAV UNI" hdr>Connection: Keep-Alive hdr>Content-Length: 19340 hdr>Content-Type: text/html hdr>Set-Cookie: lubid=010000508BD3C3F205C842E39A500005366400000000; expires=Mon, 18-Jan-2038 05:00:00 GMT; domain=.lycos.com; path=/ hdr>Set-Cookie: ASPSESSIONIDASCDAATD=LFNNLFCCPEIFBKMIKFAPFKGF; path=/ hdr>Cache-control: private On 7/24/05, Francois PIETTE <[EMAIL PROTECTED]> wrote: > Using HttpTst sample program provided with ICS, I get only on OnRequestDone > with StatusCode = 200. > Not using proxy > cmd> GET / HTTP/1.1 > cmd> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* > cmd> Connection: Keep-Alive > cmd> Accept-Language: en, fr > cmd> User-Agent: Mozilla/3.0 (compatible) > cmd> Host: help.lycos.com > cmd> > text/html => document.htm > Location = http://help.lycos.com/network_1_help.asp > URL = http://help.lycos.com > Document = document.htm > hdr>HTTP/1.1 302 Object moved > hdr>Server: Microsoft-IIS/5.0 > hdr>Date: Sun, 24 Jul 2005 08:57:30 GMT > hdr>P3P: CP="CAO DSP COR CURa ADMa DEVa CONo PSAa OUR IND DEM PRE PUR TAIa > NAV UNI" > hdr>Connection: close > hdr>Location: network_1_help.asp > hdr>Content-Length: 121 > hdr>Content-Type: text/html > hdr>Cache-control: private > Location changed to "http://help.lycos.com/network_1_help.asp" > cmd> GET /network_1_help.asp HTTP/1.1 > cmd> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* > cmd> Connection: Keep-Alive > cmd> Accept-Language: en, fr > cmd> User-Agent: Mozilla/3.0 (compatible) > cmd> Host: help.lycos.com > cmd> > Cookie: "lubid=010000508BD39CB1060842E357FA0006835F00000000; expires=Mon, > 18-Jan-2038 05:00:00 GMT; domain=.lycos.com; path=/" > Cookie: "ASPSESSIONIDQSCRSSCC=BCEDCMIAIEKNELPFODIDOLIA; path=/" > text/html => network_1_help.asp > Location = http://help.lycos.com/network_1_help.asp > URL = http://help.lycos.com > Document = network_1_help.asp > RequestDone, no error. Status =200 > StatusCode = 200 > hdr>HTTP/1.1 200 OK > hdr>Server: Microsoft-IIS/5.0 > hdr>Date: Sun, 24 Jul 2005 08:57:29 GMT > hdr>P3P: CP="CAO DSP COR CURa ADMa DEVa CONo PSAa OUR IND DEM PRE PUR TAIa > NAV UNI" > hdr>Connection: close > hdr>Content-Length: 19340 > hdr>Content-Type: text/html > hdr>Set-Cookie: lubid=010000508BD39CB1060842E357FA0006835F00000000; > expires=Mon, 18-Jan-2038 05:00:00 GMT; domain=.lycos.com; path=/ > hdr>Set-Cookie: ASPSESSIONIDQSCRSSCC=BCEDCMIAIEKNELPFODIDOLIA; path=/ > hdr>Cache-control: private > > -- > [EMAIL PROTECTED] > http://www.overbyte.be > > ----- Original Message ----- > From: "Merijn Terheggen" <[EMAIL PROTECTED]> > To: "ICS support mailing" <twsocket@elists.org> > Sent: Saturday, July 23, 2005 9:12 PM > Subject: Re: [twsocket] HttpCli StatusCode = 0 causes problems > > > > Here you go: > > > > 'http://help.lycos.com' redirects into > > 'http://help.lycos.com/network_1_help.asp'. > > > > 'http://help.lycos.com/network_1_help.asp' redirects into > > 'http://help.lycos.com/network_1_help.asp', which is into itself. > > After the 2 LocationChange events, there will be 2 RequestDone events. > > The first one with a StatusCode = 0 and the second one with a > > StatusCode = 200. > > > > --Merijn > > > > > > On 7/23/05, Francois PIETTE <[EMAIL PROTECTED]> wrote: > >> > Why is there a RequestDone event while the StatusCode is still zero > >> > anyway? > >> > >> I would be interested in finding a reproductible case where it occurs. > >> -- > >> [EMAIL PROTECTED] > >> http://www.overbyte.be > >> > >> > >> ----- Original Message ----- > >> From: "Merijn Terheggen" <[EMAIL PROTECTED]> > >> To: "ICS support mailing" <twsocket@elists.org> > >> Sent: Saturday, July 23, 2005 6:04 PM > >> Subject: [twsocket] HttpCli StatusCode = 0 causes problems > >> > >> > >> >I noticed some behavior of HttpCli that caused me a LOT of headaches > >> > before I discovered what was going on and made a work-around. > >> > > >> > This mail is to ask you: > >> > - If the behavior that I noticed indeed happens the way I describe > >> > - If the behavior is consiously designed this way or needs to be changed > >> > > >> > On the RequestDone event, the StatusCode can be 0. I only notice this > >> > happen rarely in certain cases of a redirect (FollowRelocation set to > >> > 'true'). If I've seen things correct, there can be ANOTHER RequestDone > >> > event following in this case. > >> > > >> > Why is this a problem? The RequestDone event is typically used to > >> > process the HttpCli data. After processing, the client potentially > >> > could get deleted since it has no function anymore (as happens in my > >> > code at least). However, another RequestDone event following the first > >> > one when the client has been deleted already causes access violations > >> > etc. > >> > > >> > The only way to be sure the RequestDone event is the 'final' event > >> > seems to be a check on the StatusCode. In case the StatusCode = 0, I > >> > let the event handler return because another RequestDone event will > >> > follow. > >> > > >> > Why is there a RequestDone event while the StatusCode is still zero > >> > anyway? > >> > > >> > Thanks, > >> > > >> > --Merijn > >> > -- > >> > To unsubscribe or change your settings for TWSocket mailing list > >> > please goto http://www.elists.org/mailman/listinfo/twsocket > >> > Visit our website at http://www.overbyte.be > >> > > >> > >> -- > >> To unsubscribe or change your settings for TWSocket mailing list > >> please goto http://www.elists.org/mailman/listinfo/twsocket > >> Visit our website at http://www.overbyte.be > >> > > -- > > To unsubscribe or change your settings for TWSocket mailing list > > please goto http://www.elists.org/mailman/listinfo/twsocket > > Visit our website at http://www.overbyte.be > > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be