Modify

Opened 17 years ago

Closed 17 years ago

#1049 closed Bug (Fixed)

InetRead() inserts arbitrary \0 characters.

Reported by: GEOSoft Owned by: Valik
Milestone: 3.3.1.2 Component: AutoIt
Version: 3.3.0.0 Severity: Blocking
Keywords: Cc:

Description

I'm classing this as a bug but it may be more of a feature request. InetRead() doesn't wait for the read to finish before returning.

$sTemp = @TempDir & "\cWeather.txt"
$sStr = InetRead("http://www.google.ca/ig/api?weather=nanaimo,BC", 1)
ClipPut(BinaryToString($sStr))
$sSrc = InetGet("http://www.google.ca/ig/api?weather=nanaimo,BC", $sTemp, 1)
InetClose($sSrc)
If NOT $sSrc Then Exit
ClipPut(ClipGet() & @CRLF & @CRLF & FileRead($sTemp))
FileDelete($sTemp)

This gave me the following results where the top portion is from InetRead() and The bottom is from InetGet() and FileRead().

<?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><forecast_information><city data="Nanaimo, BC"/><postal_code data="nanaimo,BC"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2009-06-29"/><current_date_time data="2009-06-29 15:07:41 +0000"/><unit_system data="US"/></forecast_information><current_conditions><condition data="Partly Cloudy"/><temp_f data="55"/><temp_c data="13"/><humidity data="Humidity: 54%"/><icon data="/ig/images/weather/partly_cloudy.gif"/><wind_condition data="Wind: W at 7 mph"/></current_conditions><forecast_conditions><day_of_week data="Mon"/><low data="50"/><high data="69"/><icon data="/ig/images/weather/partly_cloudy.gif"/><condition data="Partly Cloudy"/></forecast_conditions><forecast_conditions><day_of_week data="Tue"/><low data="51"/><high data="70"/><icon data="/ig/images/weather/sunny.gif"/><condition data="Sunny"/></forecast_conditions><forecast_conditions><day_of_week data=

<?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><forecast_information><city data="Nanaimo, BC"/><postal_code data="nanaimo,BC"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2009-06-29"/><current_date_time data="2009-06-29 15:07:41 +0000"/><unit_system data="US"/></forecast_information><current_conditions><condition data="Partly Cloudy"/><temp_f data="55"/><temp_c data="13"/><humidity data="Humidity: 54%"/><icon data="/ig/images/weather/partly_cloudy.gif"/><wind_condition data="Wind: W at 7 mph"/></current_conditions><forecast_conditions><day_of_week data="Mon"/><low data="50"/><high data="69"/><icon data="/ig/images/weather/partly_cloudy.gif"/><condition data="Partly Cloudy"/></forecast_conditions><forecast_conditions><day_of_week data="Tue"/><low data="51"/><high data="70"/><icon data="/ig/images/weather/sunny.gif"/><condition data="Sunny"/></forecast_conditions><forecast_conditions><day_of_week data="Wed"/><low data="54"/><high data="74"/><icon data="/ig/images/weather/sunny.gif"/><condition data="Sunny"/></forecast_conditions><forecast_conditions><day_of_week data="Thu"/><low data="58"/><high data="78"/><icon data="/ig/images/weather/sunny.gif"/><condition data="Sunny"/></forecast_conditions></weather></xml_api_reply>

Using _InetGetSource() works but that means there is no advantage to using the native function.

Attachments (0)

Change History (6)

comment:1 by Valik, 17 years ago

It's a bug in how the data is stored internally. I'll take care of it.

Your code is also wrong, though.

InetClose($sSrc)

$sSrc is not a handle, it's the number of bytes read.

comment:2 by Valik, 17 years ago

Owner: set to Valik
Severity: NoneBlocking
Status: newassigned
Summary: InetRead doesn't wait to finishInetRead() inserts arbitrary \0 characters.

Sigh, this is not as easy to fix as I thought. Changing the title to reflect the actual bug and setting as blocking. This needs fixed before the next beta but requires extensive changes.

in reply to:  1 comment:3 by anonymous, 17 years ago

Replying to Valik:

It's a bug in how the data is stored internally. I'll take care of it.

Your code is also wrong, though.

InetClose($sSrc)

$sSrc is not a handle, it's the number of bytes read.

Sorry about that InetClose. In my script I was testing multiple methods and that was left in from a previous test.

comment:4 by Valik, 17 years ago

Improved test script:

Local Const $sFile = @TempDir & "\inetreadtest.xml"
Local Const $sUrl = "http://www.google.ca/ig/api?weather=nanaimo,BC"
Local Const $sRead = InetRead($sUrl, 1)
Local Const $nReadSize = @extended
Local Const $nGetSize = InetGet($sUrl, $sFile, 1)
Local Const $sGet = FileRead($sFile)
FileDelete($sFile)
MsgBox(4096, "", StringFormat("Read:\t%d\nGet:\t%d\nEqual:\t%s", $nReadSize, $nGetSize, $sRead = $sGet))

in reply to:  4 comment:5 by jchd <usenet@…>, 17 years ago

Hi,

I was about reporting this problem last week but got distracted by more urgent stuff. I've had the same problem with IE6 installed, tried IE7 and IE8 (but downgraded to IE7 since IE8 seems a bit "experimental").

I don't know if this is related but, besides truncated captures, I also experienced bad results from InetRead when trying to capture slow websites. _InetGetSource is much more patient and gives good results even on pathalogically slow pages (up to 30s latency). It would be nice to have the fixed InetRead be as patient (or have a way to specify timeout for Inet* functions).

comment:6 by Valik, 17 years ago

Milestone: 3.3.1.2
Resolution: Fixed
Status: assignedclosed

Fixed in version: 3.3.1.2

Modify Ticket

Action
as closed The owner will remain Valik.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.