> Am 07.04.17 um 09:43 schrieb Wolfgang Winkler:
>> We have some long running scripts, e.g. shrinking of large PDF files,
>> and want to prevent reverse proxy and browser timeouts.
>> To achieve this, we are trying to periodically send small packages
>> from the server to the browser while these scripts are running.
Dear Wolfgang,

maybe you find the following snippet useful, which obtains a pdf file 
from an upstream server
via HTTPS with timeouts in the background. It uses the actual version of 
the
revproxy module and NaviServer, but does does not handle redirects etc. 
which
could be added to a specialized version of that backendReply handler.

-g

===================================================================
set pdfUrl https://www.w3.org/Protocols/HTTP/1.1/rfc2616.pdf
set timeout 10.0

if {[catch {
     set queryHeaders [ns_conn headers]
     ns_set update $queryHeaders X-Forwarded-For [ns_conn peeraddr]
     ns_set update $queryHeaders Connection close
     
     set pdfChan [ns_connchan open \
                     -method GET \
                     -headers $queryHeaders \
                     -timeout $timeout \
                     -version 1.0 \
                     $pdfUrl]
} errorMsg]} {
     ns_return 408 text/plain "error while trying to obtain 
$pdfUrl\n($errorMsg)"
} else {
     set frontendChan [ns_connchan detach]
     ns_connchan callback -timeout $timeout $pdfChan  \
        [list ::revproxy::backendReply $pdfChan $frontendChan $pdfUrl $timeout 
0] rex
}
===================================================================


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to