Modify

Opened 10 years ago

Closed 10 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 follow-up: Changed 10 years ago by 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.

comment:2 Changed 10 years ago by Valik

  • Owner set to Valik
  • Severity changed from None to Blocking
  • Status changed from new to assigned
  • Summary changed from InetRead doesn't wait to finish to InetRead() 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.

comment:3 in reply to: ↑ 1 Changed 10 years ago by anonymous

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 follow-up: Changed 10 years ago by Valik

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))

comment:5 in reply to: ↑ 4 Changed 10 years ago by jchd <usenet@…>

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 Changed 10 years ago by Valik

  • Milestone set to 3.3.1.2
  • Resolution set to Fixed
  • Status changed from assigned to closed

Fixed in version: 3.3.1.2

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Valik.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.