~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/HTTPTestUtil.py

  • Committer: Alexander Belchenko
  • Date: 2007-01-04 23:36:44 UTC
  • mfrom: (2224 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2225.
  • Revision ID: bialix@ukr.net-20070104233644-7znkxoj9b0y7ev28
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import errno
19
19
from SimpleHTTPServer import SimpleHTTPRequestHandler
20
20
import socket
 
21
import urlparse
21
22
 
22
23
from bzrlib.tests import TestCaseWithTransport
23
24
from bzrlib.tests.HttpServer import (
206
207
    """Append a '-proxied' suffix to file served"""
207
208
 
208
209
    def translate_path(self, path):
209
 
        return TestingHTTPRequestHandler.translate_path(self,
210
 
                                                        path + '-proxied')
 
210
        # We need to act as a proxy and accept absolute urls,
 
211
        # which SimpleHTTPRequestHandler (grand parent) is not
 
212
        # ready for. So we just drop the protocol://host:port
 
213
        # part in front of the request-url (because we know we
 
214
        # would not forward the request to *another* proxy).
 
215
 
 
216
        # So we do what SimpleHTTPRequestHandler.translate_path
 
217
        # do beginning with python 2.4.3: abandon query
 
218
        # parameters, scheme, host port, etc (which ensure we
 
219
        # provide the right behaviour on all python versions).
 
220
        path = urlparse.urlparse(path)[2]
 
221
        # And now, we can apply *our* trick to proxy files
 
222
        self.path += '-proxied'
 
223
        # An finally we leave our mother class do whatever it
 
224
        # wants with the path
 
225
        return TestingHTTPRequestHandler.translate_path(self, path)
 
226
 
211
227
 
212
228