/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    http://www.python.org/dev/peps/pep-0333/
21
21
"""
22
22
 
23
 
from io import BytesIO
 
23
from __future__ import absolute_import
24
24
 
 
25
from ...sixish import (
 
26
    BytesIO,
 
27
    )
25
28
from ...bzr.smart import medium
26
29
from ...transport import chroot, get_transport
27
30
from ...urlutils import local_path_to_url
28
31
 
29
32
 
30
33
def make_app(root, prefix, path_var='REQUEST_URI', readonly=True,
31
 
             load_plugins=True, enable_logging=True):
 
34
    load_plugins=True, enable_logging=True):
32
35
    """Convenience function to construct a WSGI bzr smart server.
33
36
 
34
37
    :param root: a local path that requests will be relative to.
114
117
        # protocol dictionary, we don't *just in case* there are parts of
115
118
        # breezy that will invoke 'get_transport' on urls rather than cloning
116
119
        # around the existing transport.
117
 
        # self.chroot_server.stop_server()
 
120
        #self.chroot_server.stop_server()
118
121
 
119
122
    def __call__(self, environ, start_response):
120
123
        """WSGI application callable."""
137
140
            # Remove the root_client_path from the relpath, and set
138
141
            # adjusted_tcp to None to tell the request handler that no further
139
142
            # path translation is required.
140
 
            adjusted_rcp = '.'
 
143
            adjusted_rcp = None
141
144
            adjusted_relpath = relpath[len(self.root_client_path):]
142
145
        elif self.root_client_path.startswith(relpath):
143
146
            # The relpath traverses some of the mandatory root client path.
159
162
        request_data_length = int(environ['CONTENT_LENGTH'])
160
163
        request_data_bytes = environ['wsgi.input'].read(request_data_length)
161
164
        smart_protocol_request = self.make_request(
162
 
            transport, out_buffer.write, request_data_bytes,
163
 
            adjusted_rcp)
 
165
            transport, out_buffer.write, request_data_bytes, adjusted_rcp)
164
166
        if smart_protocol_request.next_read_size() != 0:
165
167
            # The request appears to be incomplete, or perhaps it's just a
166
168
            # newer version we don't understand.  Regardless, all we can do
167
169
            # is return an error response in the format of our version of the
168
170
            # protocol.
169
 
            response_data = b'error\x01incomplete request\n'
 
171
            response_data = 'error\x01incomplete request\n'
170
172
        else:
171
173
            response_data = out_buffer.getvalue()
172
174
        headers = [('Content-type', 'application/octet-stream')]