Basic libURL bug?

Dave Cragg dave.cragg at
Sun Jan 2 21:12:17 EST 2011

On 3 Jan 2011, at 00:34, Mark Wieder wrote:

> Chipp-
> Sunday, January 2, 2011, 4:26:40 PM, you wrote:
>> Even more interesting. On my Mac, it returns correctly, just not on my PC.
> Yep. I can verify that here. Returns 4558 every time on OSX. On XP I'm
> getting different results. Sometimes 4558, sometimes 0 (I added a "put
> the result into field 2" and sometimes find interesting things there:
> "error No Header received"), I've gotten 1583, 3675...

I'm also seeing strange results on Windows. 

At first it seemed like random quantities of data were being received, but now it seems "stable" and consistently receives 207169 bytes of data (out of 1079427).

Some stranger stuff... 

I tried to trace what was happening in libUrl. (edit script of button "revLibUrl" of stack "revLibrary")

In the libUrl script there is a handler named ulDoProcessLength. The start of this handler looks like this, except for the two "DEBUG" lines I added. If you uncomment these, they will output into a field that you can set with libUrlSetLogField.

on ulDoProcessLength x,y
   local tStatus
   ##normal http case
   if y <> empty then
      ulStoreData laUrl[x],y
      add length(y) to laReadBytes[laUrl[x]]
      //ulLogIt laReadBytes[laUrl[x]] & "," & length(y) & cr //DEBUG 1 -ADDED BY ME
   end if
   if laReadBytes[laUrl[x]] >= laLength[laUrl[x]] then
      put "true" into laStatus[laUrl[x]]
      //ulLogIt  laReadBytes[laUrl[x]] & ", " &  laLength[laUrl[x]] & "," & length(y) &  cr //DEBUG 2 - ADDED BY ME
      if char 1 of laStatusCode[laUrl[x]] = 2 then ##in 200 range--OK
         if laFile[laUrl[x]] is empty then
            put "cached" into tStatus
            put "downloaded" into tStatus
         end if

If I uncomment the first DEBUG line, all the data gets downloaded. This seems to be consistent. Not sure what this means, but at a guess, I'd say the short time used to log the data is allowing LC to read properly from the socket.

But stranger still...

If I uncomment the second debug line (and comment the first one), it outputs this in the log field:

207169, 1079427,1440

Given the condition in the "if" line, this should be impossible. 

Maybe I've had too much sherry over the holiday, so if someone would like to try and see if they see the same it would be interesting.

One question, Chipp. Is there anything in the data that might "upset" LC and therefore cause stange comparison results?


More information about the Use-livecode mailing list