direct http port access for web proxy
[1/3] from: anton::lexicon::net at: 6-Apr-2002 19:05
Hello,
I am working on a web-proxy that runs locally on my
machine. I have had it running without the /direct
refinement and it works ok, but because it buffers
all the data in memory, the browser might time out
waiting for a large file from my proxy.
Hence, I am trying now to deliver data in chunks,
but I am having trouble getting the request.
Essentially I am doing it like this:
listen-port: open/binary/direct tcp://:8080
; now wait for browser to make a request
http-port: first wait listen-port
; This causes network timeout error...
while [data: copy/part http-port 1024][append request data]
; now examine the request to discover the url,
; run off and get the data in chunks and
; write it back to the http-port
This is the error:
** Access Error: Network timeout
** Where: forever
** Near: probe data: copy/part http-port 1024
Has anyone got any pointers or links to docs for this?
I have read the core2.3.pdf on ports and had a bit of
a trawl through the script library but failed to find
a sufficiently similar example.
Anton.
[2/3] from: rebolinth:nodep:dds:nl at: 6-Apr-2002 12:01
Hello Anton,
I think ! ( so therefor I am ...not 100% a rebol guru yet ;-)
Because you use the /direct there is nothing to wait for.
Your while [] loop will always be true.
(R)egards,
Norman
[3/3] from: rebolinth:nodep:dds:nl at: 6-Apr-2002 12:25
Hiya anton,
I did some sniffing and found this in the rebol/core manual:
The copy function will return none when all data have been read from a port.
When running in /nowait mode, the copy function will return an empty string if
no data is available for the port.
tp: open/direct/binar/nowait tcp://system:8000
content: make binary! 1000
while [wait tp data: copy tp] [append content data]
close tp
(R)egards,
Norman.