[Inteproxy-commits] r41 - trunk
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Apr 11 15:14:49 CEST 2007
Author: bh
Date: 2007-04-11 15:14:49 +0200 (Wed, 11 Apr 2007)
New Revision: 41
Modified:
trunk/ChangeLog
trunk/InteProxy.py
trunk/transcoder.py
Log:
* transcoder.py (TranscoderMap.get_transcoder, get_transcoder):
Turn the get_transcoder function into a method of TranscoderMap.
* InteProxy.py (InteProxyHTTPRequestHandler.handle_proxy_request):
get_transcoder is now a method of the transcoder map.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-04-11 12:58:39 UTC (rev 40)
+++ trunk/ChangeLog 2007-04-11 13:14:49 UTC (rev 41)
@@ -1,5 +1,13 @@
2007-04-11 Bernhard Herzog <bh at intevation.de>
+ * transcoder.py (TranscoderMap.get_transcoder, get_transcoder):
+ Turn the get_transcoder function into a method of TranscoderMap.
+
+ * InteProxy.py (InteProxyHTTPRequestHandler.handle_proxy_request):
+ get_transcoder is now a method of the transcoder map.
+
+2007-04-11 Bernhard Herzog <bh at intevation.de>
+
* transcoder.py (get_transcoder): Simplify the logic. We only
need to special case the "old" inteproxy style
Modified: trunk/InteProxy.py
===================================================================
--- trunk/InteProxy.py 2007-04-11 12:58:39 UTC (rev 40)
+++ trunk/InteProxy.py 2007-04-11 13:14:49 UTC (rev 41)
@@ -25,7 +25,7 @@
import Queue
import socket
import proxyconnection
-from transcoder import get_transcoder, transcoder_map
+from transcoder import transcoder_map
inteproxy_version = "0.1.2"
@@ -101,7 +101,7 @@
#
# Create a http request for the real location
#
- transcoder = get_transcoder(method, self.path)
+ transcoder = transcoder_map.get_transcoder(method, self.path)
remote_url = transcoder.get_url()
self.log_debug("Converted url: %r", remote_url)
Modified: trunk/transcoder.py
===================================================================
--- trunk/transcoder.py 2007-04-11 12:58:39 UTC (rev 40)
+++ trunk/transcoder.py 2007-04-11 13:14:49 UTC (rev 41)
@@ -162,6 +162,46 @@
classname = self.hostmap.get((host, path), self.default_classname)
return self.classmap[classname][method]
+ def get_transcoder(self, method, url):
+ """Returns a transcoder for the given HTTP method and URL
+
+ URL should be the URL given for the GET or POST http request.
+ This function extracts the real remote host from the URL and
+ uses the URL to look up the transcoder with lookup_transcoder.
+
+ This method supports two ways to encode the remote host in the
+ URL:
+
+ -- InteProxy is accessed directly as an HTTP server. In this
+ cases URL is an absolute pathname and does not include a
+ hostname in the normal URL syntax. Instead get_transcoder
+ assumes that it encodes the real remote host in the first
+ component of the path. This is the old InteProxy method
+
+ -- InteProxy is used as a HTTP-proxy. In this case URL will
+ be a full URL including a hostname. In this case
+ get_transcoder will use the host of the URL as the real
+ remote host. The path component of the URL is not
+ modified.
+ """
+ scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
+
+ # If scheme is given, InteProxy is used as a HTTP proxy, otherwise
+ # it's the old InteProxy approach. Only the old approach needs
+ # special casing.
+ if not scheme:
+ scheme = "http"
+ # determine the remote host encoded in the path
+ split_path = path.split("/")
+ if not split_path[0]:
+ del split_path[0]
+ netloc = split_path.pop(0)
+ path = "/" + "/".join(split_path)
+
+ transcoder_class = self.lookup(method, netloc, path)
+ return transcoder_class(method,
+ (scheme, netloc, path, query, fragment))
+
def read_config(self, filename):
"""Reads a configuration file and adds the host descriptions found"""
parser = SafeConfigParser()
@@ -179,43 +219,3 @@
("owsproxy", OWSProxyGETTranscoder, OWSProxyPOSTTranscoder),
])
transcoder_map = create_transcoder_map()
-
-
-def get_transcoder(method, url):
- """Return a transcoder for the given HTTP method and URL
-
- URL should be the URL given for the GET or POST http request. This
- function extracts the real remote host from the URL and uses the URL
- to look up the transcoder with lookup_transcoder.
-
- This function supports two ways to encode the remote host in the
- URL:
-
- -- InteProxy is accessed directly as an HTTP server. In this
- cases URL is an absolute pathname and does not include a
- hostname in the normal URL syntax. Instead get_transcoder
- assumes that it encodes the real remote host in the first
- component of the path. This is the old InteProxy method
-
- -- InteProxy is used as a HTTP-proxy. In this case URL will be a
- full URL including a hostname. In this case get_transcoder
- will use the host of the URL as the real remote host. The
- path component of the URL is not modified.
- """
- scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
-
- # If scheme is given, InteProxy is used as a HTTP proxy, otherwise
- # it's the old InteProxy approach. Only the old approach needs
- # special casing.
- if not scheme:
- scheme = "http"
- # determine the remote host encoded in the path
- split_path = path.split("/")
- if not split_path[0]:
- del split_path[0]
- netloc = split_path.pop(0)
- path = "/" + "/".join(split_path)
-
- transcoder_class = transcoder_map.lookup(method, netloc, path)
- return transcoder_class(method,
- (scheme, netloc, path, query, fragment))
More information about the Inteproxy-commits
mailing list