It looks like the stream seek() method does not work with http strings. Is there any way to cache http streams?
--EDIT--
Well, I looked at the HTTPStream source, and I came up with this. Fortunately new stream factories get higher priority, so you can just import this and it will override BRL's httpstream behavior:
Strict
Import BRL.SocketStream
Import BRL.BankStream
Type TCachedHTTPStreamFactory Extends TStreamFactory
Method CreateStream:TStream( url:Object,proto$,path$,readable,writeable )
Notify 1
If proto<>"http" Return
Local i=path.Find( "/",0 ),server$,file$
If i<>-1
server=path[..i]
file=path[i..]
Else
server=path
file="/"
EndIf
Local stream:TStream=TSocketStream.CreateClient( server,80 )
If Not stream Return
stream.WriteLine "GET "+file+" HTTP/1.0"
stream.WriteLine "Host: "+server
stream.WriteLine ""
While Not Eof( stream )
If Not stream.ReadLine() Exit
Wend
Local bank:TBank=CreateBank()
Local bs=0
While Not stream.Eof()
bs:+1
bank.resize bs
bank.PokeByte bs-1,Stream.ReadByte()
Wend
stream.close()
stream=CreateBankStream(bank)
Return stream
EndMethod
End Type
New TCachedHTTPStreamFactory
|