From: Brent W. <bre...@in...> - 2000-12-04 18:51:18
|
The latest version of TclHttpd contains these bits of code to support the proxy case, but I haven't actually used it yet: This is in HttpdRead: Here is where it is looking at the GET/POST requests. If you are a proxy, you see GET http://server:port/url HTTP/1.0 If you are not a proxy, you just get GET /url HTTP/1.0 # Strip leading http://server and look for the proxy case. if {[regexp {^https?://([^/:]+)(:([0-9]+))?(.*)$} $data(url) \ x xserv y xport urlstub]} { set myname [Httpd_Name $sock] set myport [Httpd_Port $sock] if {([string compare \ [string tolower $xserv] \ [string tolower $myname]] != 0) || ($myport != $xport)} { set data(host) $xserv set data(port) $xport } # Strip it out if it is for us (i.e., redundant) # This makes it easier for doc handlers to # look at the "url" set data(url) $urlstub } Then later, when you have the request all ready, it does this: # Do a different dispatch for proxies. By default, no proxy. if {[info exist data(host)]} { if {[catch { Proxy_Dispatch $sock } err]} { Httpd_Error $sock 400 "No proxy support\n$err" } } else { # Dispatch to the URL implementation. # As a service for domains that loose track of their # context (e.g., .tml pages) we save the socket in a global. # If a domain implementation would block and re-enter the # event loop, it must use Httpd_Suspend to clear this state, # and use Httpd_Resume later to restore it. set Httpd(currentSocket) $sock CountStart serviceTime $sock Url_Dispatch $sock } There is no "Proxy_Dispatch" in the source code - you'll have to supply your own. Let us know how it goes! -- Brent Welch <bre...@in...> http://www.interwoven.com |