~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/wsgi.py

  • Committer: Vincent Ladeuil
  • Date: 2016-02-01 19:26:41 UTC
  • mto: This revision was merged to the branch mainline in revision 6616.
  • Revision ID: v.ladeuil+lp@free.fr-20160201192641-mzn90m51rydhw00n
Open trunk again as 2.8b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
    http://www.python.org/dev/peps/pep-0333/
21
21
"""
22
22
 
 
23
from __future__ import absolute_import
 
24
 
23
25
from cStringIO import StringIO
24
26
 
25
 
from bzrlib.smart import protocol, medium
 
27
from bzrlib.smart import medium
26
28
from bzrlib.transport import chroot, get_transport
27
29
from bzrlib.urlutils import local_path_to_url
28
30
 
101
103
            backing_transport.  This is used to interpret relpaths received from
102
104
            the client.
103
105
        """
104
 
        # Use a ChrootTransportDecorator so that this web application won't
 
106
        # Use a ChrootServer so that this web application won't
105
107
        # accidentally let people access locations they shouldn't.
106
108
        # e.g. consider a smart server request for "get /etc/passwd" or
107
109
        # something.
108
110
        self.chroot_server = chroot.ChrootServer(backing_transport)
109
 
        self.chroot_server.setUp()
 
111
        self.chroot_server.start_server()
110
112
        self.backing_transport = get_transport(self.chroot_server.get_url())
111
113
        self.root_client_path = root_client_path
112
114
        # While the chroot server can technically be torn down at this point,
114
116
        # protocol dictionary, we don't *just in case* there are parts of
115
117
        # bzrlib that will invoke 'get_transport' on urls rather than cloning
116
118
        # around the existing transport.
117
 
        #self.chroot_server.tearDown()
 
119
        #self.chroot_server.stop_server()
118
120
 
119
121
    def __call__(self, environ, start_response):
120
122
        """WSGI application callable."""
176
178
    def make_request(self, transport, write_func, request_bytes, rcp):
177
179
        protocol_factory, unused_bytes = medium._get_protocol_factory_for_bytes(
178
180
            request_bytes)
179
 
        server_protocol = protocol_factory(transport, write_func, rcp)
 
181
        server_protocol = protocol_factory(
 
182
            transport, write_func, rcp, self.backing_transport)
180
183
        server_protocol.accept_bytes(unused_bytes)
181
184
        return server_protocol