Discussion:
InternetReadFile returns incomplete page.
(too old to reply)
Skybuck Flying
2005-11-23 11:58:16 UTC
Permalink
The problem is bigger than I thought.

Even with a big buffer like 1 MB it doesn't work well.

Bye,
Skybuck.
Hi,
Problem: InternetReadFile returns true and BytesRead is zero while in
reality there should be more bytes.
Question: What is causing this problem ?
The buffer supplied to InternetReadFile is 4 KB.
If the buffer supplied to InternetReadFile is much larger, for example 4
MB,
this problem does not occur ?!
vFlags := INTERNET_FLAG_NO_CACHE_WRITE;
vFlags := INTERNET_FLAG_NO_CACHE_WRITE or INTERNET_FLAG_RELOAD;
vContext := 0;
function Thttp.RetrieveText : boolean;
begin
result := false;
mText := '';
while true do
begin
if InternetReadFile(
mInternetHTTPHandle,
mInternalBuffer,
mInternalBufferSize,
mInternalBufferBytes ) then
begin
// buffer bytes read
if mInternalBufferBytes > 0 then
begin
mText := mText + Pchar(mInternalBuffer);
end else
if mInternalBufferBytes = 0 then
begin
result := true;
// end of file reached
break;
end;
end else
begin
mLastError := GetLastError;
break;
end;
end;
end;
I would like to know what could be causing this problem, any ideas ?
Bye,
Skybuck.
Skybuck Flying
2005-11-23 15:15:12 UTC
Permalink
Well,

I have tracked down some bugs:

Bugs:

1. Tmemo doesn't like it when text with control characters are added.
2. TrichEdit doesn't like it when text with control characters are added.
3. mText := mText + Pchar(mInternalBuffer);

Bug in RetrieveText function:

Delphi will only copy the content in the internal buffer up to the null
terminated character ;)

^^ pretty retarded =D lol.

I have greatly under estimated the effort required to test the http
component.

The retrieved http text contains all kinds of raw binary strings which fucks
up the debug/test methods ;)

Working with text with control characters is ttttrrrrriiiiiiicky !

For now everything seems to be working fine... which is kinda weird...
because I could have sworn that it didn't return enough bytes during
debugging...

So the wininet dll might still have a bug. Further testing is necessary :)

Bye,
Skybuck.
Post by Skybuck Flying
The problem is bigger than I thought.
Even with a big buffer like 1 MB it doesn't work well.
Bye,
Skybuck.
Hi,
Problem: InternetReadFile returns true and BytesRead is zero while in
reality there should be more bytes.
Question: What is causing this problem ?
The buffer supplied to InternetReadFile is 4 KB.
If the buffer supplied to InternetReadFile is much larger, for example 4
MB,
this problem does not occur ?!
vFlags := INTERNET_FLAG_NO_CACHE_WRITE;
vFlags := INTERNET_FLAG_NO_CACHE_WRITE or INTERNET_FLAG_RELOAD;
vContext := 0;
function Thttp.RetrieveText : boolean;
begin
result := false;
mText := '';
while true do
begin
if InternetReadFile(
mInternetHTTPHandle,
mInternalBuffer,
mInternalBufferSize,
mInternalBufferBytes ) then
begin
// buffer bytes read
if mInternalBufferBytes > 0 then
begin
mText := mText + Pchar(mInternalBuffer);
end else
if mInternalBufferBytes = 0 then
begin
result := true;
// end of file reached
break;
end;
end else
begin
mLastError := GetLastError;
break;
end;
end;
end;
I would like to know what could be causing this problem, any ideas ?
Bye,
Skybuck.
Loading...