[Theo Verelst] Inspired by some work I did some time ago, where I wanted to be sure what a certain internet connection would do, and made a small [proxy] server for simple [http] requests, I thought I'd put it up here, maybe some people can have fun with it. The POST section doesn't work (probably not at all) I'm looking into it, because I wanted to record data going to some form I want to fill with tcl, probably not too nice practice, but then again, why not. ################################ proxy.tcl #################################### proc proxysocket {{port 3000}} { global serversock set serversock [socket -server proxyservsetevent $port] } proc proxyservsetevent {s i p} { fconfigure $s -encoding binary fconfigure $s -translation binary fconfigure $s -blocking 0 fileevent $s readable "proxyservfirstevent $s" } proc proxyservfirstevent {s} { global in gets $s in set l1 [split [lindex [split $in \n] 0] " "] set command [lindex $l1 0] set url [lindex $l1 1] set proto [lindex $l1 2] #puts $url puts $in puts "url=$url" if {$url == "http://test"} {puts $s "Test !"; close $s; return} switch $command { GET { set hh [http::geturl $url -command "proxyfeedpage $s" ] fileevent $s readable "proxyservnextevent $s" } POST { set hh [http::geturl $url -command "proxyfeedpage $s" -querychannel $s ] # fileevent $s readable "proxyservnextevent $s" } } } proc proxyservnextevent {s} { gets $s in # ignored for now } proc proxygeturl {s h} { } proc proxyfeedpage {s h} { puts $s [http::data $h] flush $s proxyclosepage $s $h } proc proxyclosepage {s h} { http::cleanup $h close $s } proc proxyinit {} { package require http proxysocket 3000 } console show # Use this to start the nano proxyserver: proxyinit ---- You should adjust your browser to proxy address localhost with port 3000 to get data from the web over this proxy. Normal pages with pictures are fine, the url's are listed on the console. Of course you could run the proxy on another machine than you use to surf. ---- When making this page, I got to the edit page via the above proxy, and had to switch back to direct link to do the 'save' operation... ---- By valli The probable reason for this failing for post requests is . It is said not to use gets on binary IO stream. It is recommended to use read. refer: http://wiki.tcl.tk/1180 I am not sure, this is just my reasoning ---- [Category Networking]