On Tue, Aug 10, 2010 at 10:05 AM, Lostgallifreyan <z.c...@btinternet.com> wrote:
> Can anyone tell me why this fails?

Unfortunately no, but http://www.google.com and yahoo.com work fine.

> It seems that while the code 'CanRead()' the URL's stream just fine, it 
> cannot actually 'Read()' it at all!
> Substituting other URL and direct file references, even local ones, works 
> fine, as does a directly fetched
> copy of the page I'm after, stored locally. It is impossible to read this 
> stream directly from the remote source.
> Why?
>
> function HTTP_GET(URL)  local T,S={}
>  S=wx.wxURL(URL):GetInputStream()  while S:CanRead() do  
> table.insert(T,S:Read(64))  end
>  return table.concat(T)
> end
>
>
> HTTP_GET("http://www.metoffice.com/satpics/latest_uk_ir.html";)

I recommend making the wxURL object local so that it is more obvious
that it will be destroyed, otherwise it will be global. The print
statement below says that 0 bytes were read, but that there was
wxURL_NOERR. I think there is a website that will tell you what
webserver is used for any given site, maybe there's something off with
their server?

function iff(a, b, c) if a then return b else return c end end

function HTTP_GET(URL)
  local T = {}
  local U = wx.wxURL(URL)    -- Make local
  local S = U:GetInputStream()
  local i = 1
  while S:CanRead() do
    a = S:Read(64)
    print(string.format("%d: %d : %d : Err %d : '%s'\n", i,
S:LastRead(), iff(S:Eof(), 1, 0), U:GetError(), a))
    table.insert(T,a)
    i = i + 1
    if i == 10 then break; end
  end

  return table.concat(T), T
 end


Regards,
    John Labenski

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to