Topic: Vivtek dumbproxy -- code

dumbproxy index ]
This is it. Pretty exciting.
ns_register_proc -noinherit GET /dumbproxy dumbproxy

proc dumbproxy {conn ignore} {
   set form [ns_conn form $conn]

   if {$form == ""} { set form [ns_set create] } ;# Blank form if none.

   set url [ns_set get $form url]
   set hochecked ""
   set what all
   if {[ns_set find $form headeronly] > -1} { set what header; set hochecked " checked" }

   if [string compare $url ""] {
      # Do the browser thing.
      set r [vv_http make $url]
      set s [vv_http request $r $what]
   } else { set s "" }

   regsub -all "&" $s "\\&" s
   regsub -all "<" $s "\\&lt;" s
   regsub -all ">" $s "\\&gt;" s

   ns_return $conn 200 text/html "
<html><head><title>Vivtek dumb proxy - $url</title></head>
<body>
<h2>Vivtek dumb proxy</h2>
<font size=-1><a href=\"/dumbproxy.html\">Dumb proxy info, source, etc.</a></font>
<form action=\"/dumbproxy\">
Get URL: <input name=url size=60 value=\"$url\"><input type=submit value=Go!>
<br>
<input type=checkbox name=headeronly value=yes$hochecked>Show headers only, I'm in a hurry.
</form>
<hr>
<pre>
$s
</pre>
"
}





Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.