Thread View: borland.public.cppbuilder.internet.web
9 messages
9 total messages
Started by Keith
Thu, 05 May 2005 23:53
IdHTTP Get exception
Author: Keith
Date: Thu, 05 May 2005 23:53
Date: Thu, 05 May 2005 23:53
13 lines
1153 bytes
1153 bytes
Anyone able to explain why the following causes exception EConvertError
with message "Invalid argument to date encode" ?
void __fastcall TForm1::Button3Click(TObject *Sender)
{
IdHTTP1->CleanupInstance();
RichEdit1->Text=IdHTTP1->Get("http://classifieds.excite.com/index.html");
}
TIA
keith
Re: IdHTTP Get exception
Author: Remy Lebeau (TeamB)
Date: Fri, 06 May 2005 00:21
Date: Fri, 06 May 2005 00:21
15 lines
1410 bytes
1410 bytes
"Keith" <kdopson@sbcglobal.net> wrote in message
news:427AB1E6.60A6005E@sbcglobal.net...
> IdHTTP1->CleanupInstance();
Why are you calling that? NEVER NEVER NEVER call CleanupInstance()
directly!!! The VCL documentation even says as much.
> RichEdit1->Text=IdHTTP1->Get("http://classifieds.excite.com/index.html");
Works fine for me. Which version of Indy are you actually using?
Gambit
Re: IdHTTP Get exception
Author: Keith
Date: Fri, 06 May 2005 01:10
Date: Fri, 06 May 2005 01:10
29 lines
1672 bytes
1672 bytes
"Remy Lebeau (TeamB)" wrote:
> "Keith" <kdopson@sbcglobal.net> wrote in message
> news:427AB1E6.60A6005E@sbcglobal.net...
>
> > IdHTTP1->CleanupInstance();
>
> Why are you calling that? NEVER NEVER NEVER call CleanupInstance()
> directly!!! The VCL documentation even says as much.
Some legacy line, no doubt... I removed it.
> > RichEdit1->Text=IdHTTP1->Get("http://classifieds.excite.com/index.html");
>
> Works fine for me. Which version of Indy are you actually using?
Indy 9.00.11 (2003)
Curiously, the Get() does return the URL's html content, and it appears to be
complete.
Also, the after the exception dialog box is dismissed, the debug cursor is
still pointing to the Get() line.
Example project is on the attachments group.
keith
Re: IdHTTP Get exception
Author: Keith
Date: Fri, 06 May 2005 01:11
Date: Fri, 06 May 2005 01:11
9 lines
1151 bytes
1151 bytes
> Works fine for me. Which version of Indy are you actually using? > > And BCB5 Enterprise. k
Re: IdHTTP Get exception
Author: Keith
Date: Fri, 06 May 2005 01:40
Date: Fri, 06 May 2005 01:40
35 lines
1661 bytes
1661 bytes
Tracing the IdHTTP.pas file, I see this:
in procedure TIdCustomHTTP.DoRequest(const AMethod: TIdHTTPMethod; AURL:
string;
:
:
FHTTPProto.RetrieveHeaders;
and that traces into
procedure TIdHTTPProtocol.RetrieveHeaders;
:
:
Response.ProcessHeaders;
and that traces into file IdHTTPHeaderInfo.pas
procedure TIdResponseHeaderInfo.ProcessHeaders;
:
:
inherited ProcessHeaders;
and that traces into
procedure TIdEntityHeaderInfo.ProcessHeaders;
:
:
FExpires := GMTToLocalDateTime(Values['Expires']); {do not localize}
and this line --^ causes the exception (after the call
Idheaderlist::TIdHeaderList::GetValue, there is a call to
Idglobal::GMTToLocalDateTime Idglobal::GMTToLocalDateTime causes the actual
exception)
keith
Re: IdHTTP Get exception
Author: Remy Lebeau (TeamB)
Date: Fri, 06 May 2005 09:07
Date: Fri, 06 May 2005 09:07
12 lines
1375 bytes
1375 bytes
"Keith" <kdopson@sbcglobal.net> wrote in message news:427AC3FE.C00C80D0@sbcglobal.net... > Indy 9.00.11 (2003) That is a very old version. You should consider upgrading to the latest snapshot version (9.0.50) to make sure that you have all of the latest bug fixes and features available. Gambit
Re: IdHTTP Get exception
Author: Keith
Date: Fri, 06 May 2005 12:10
Date: Fri, 06 May 2005 12:10
38 lines
1870 bytes
1870 bytes
"Remy Lebeau (TeamB)" wrote:
> "Keith" <kdopson@sbcglobal.net> wrote in message
> news:427AC3FE.C00C80D0@sbcglobal.net...
>
> > Indy 9.00.11 (2003)
>
>
Thanks for the suggestion. Updating had no effect, though.
The exception occurs when
FExpires := GMTToLocalDateTime(Values['Expires']); {do not localize}
and Values['Expires'] is a pointer to the null-terminated string -1, as:
-1\0
or '-1'
This is from procedure TIdEntityHeaderInfo.ProcessHeaders;
function GMTToLocalDateTime(S: string): TDateTime; calls
Result := RawStrInternetToDateTime(S); passing a pointer to -1 as S
This causes Result := EncodeDate(Yr, Mo, Dt); to pass Yr=1900, Mo=0,
Dt=-1, and an exception is thrown by Sysutils::EncodeDate
So, all in all, when the HTTP header string Values['Expires'] either is -1, or
is set to -1, then the problem exists.
keith
Re: IdHTTP Get exception
Author: Keith
Date: Fri, 06 May 2005 14:06
Date: Fri, 06 May 2005 14:06
47 lines
2209 bytes
2209 bytes
The server reply header contains the entry:
Expires: -1
This causes the exception.
If I manually alter the buffer to:
Expires: 0\0
there is no exception when Response.ProcessHeaders;
is called from IdHTTP.pas, procedure TIdHTTPProtocol.RetrieveHeaders;
Here is what happens in IdHTTPHeaderInfo.pa, procedure
TIdEntityHeaderInfo.ProcessHeaders:
if StrToIntDef(Values['Expires'], -1) <> -1 then begin
// This is happening when expires is returned as integer number in seconds
LSecs := StrToInt(Values['Expires']);
LHours := LSecs div 3600;
LMinutes := (LSecs mod 3600) div 60;
LSecs := (LSecs mod 3600) mod 60;
FExpires := Now + EncodeTime(LHours, LMinutes, LSecs, 0);
end
else begin
FExpires := GMTToLocalDateTime(Values['Expires']); {do not localize}
end;
-------------------
GMTToLocalDateTime('-1'); will fail as it calls
function RawStrInternetToDateTime(var Value: string): TDateTime;
with pointer to -1 which causes
Result := EncodeDate(Yr, Mo, Dt); to throw exception due to invalid parameters
Dt=-1,
Mo=0, and
Yr=1900
How should these function be restructured to allow server header reply
Expires: -1
keith
Re: IdHTTP Get exception
Author: Keith
Date: Fri, 06 May 2005 14:37
Date: Fri, 06 May 2005 14:37
8 lines
1132 bytes
1132 bytes
Remy, Blasted... it's handled by try finally...... and result is set to 0... I was taken in by the debugger options language exceptions non-setting... Thanks for the help anyway... keith
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads