~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2007-04-28 15:04:17 UTC
  • mfrom: (2466 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2566.
  • Revision ID: john@arbash-meinel.com-20070428150417-trp3pi0pzd411pu4
[merge] bzr.dev 2466

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from cStringIO import StringIO
24
24
 
25
 
from bzrlib.transport import chroot, get_transport, remote
 
25
from bzrlib.smart import protocol
 
26
from bzrlib.transport import chroot, get_transport
26
27
from bzrlib.urlutils import local_path_to_url
27
28
    
28
29
 
113
114
        relpath = environ['bzrlib.relpath']
114
115
        transport = self.backing_transport.clone(relpath)
115
116
        out_buffer = StringIO()
116
 
        smart_protocol_request = self.make_request(transport, out_buffer.write)
117
117
        request_data_length = int(environ['CONTENT_LENGTH'])
118
118
        request_data_bytes = environ['wsgi.input'].read(request_data_length)
119
 
        smart_protocol_request.accept_bytes(request_data_bytes)
 
119
        smart_protocol_request = self.make_request(
 
120
            transport, out_buffer.write, request_data_bytes)
120
121
        if smart_protocol_request.next_read_size() != 0:
121
122
            # The request appears to be incomplete, or perhaps it's just a
122
123
            # newer version we don't understand.  Regardless, all we can do
130
131
        start_response('200 OK', headers)
131
132
        return [response_data]
132
133
 
133
 
    def make_request(self, transport, write_func):
134
 
        return protocol.SmartServerRequestProtocolOne(transport, write_func)
 
134
    def make_request(self, transport, write_func, request_bytes):
 
135
        # XXX: This duplicates the logic in
 
136
        # SmartServerStreamMedium._build_protocol.
 
137
        if request_bytes.startswith(protocol.REQUEST_VERSION_TWO):
 
138
            protocol_class = protocol.SmartServerRequestProtocolTwo
 
139
            request_bytes = request_bytes[len(protocol.REQUEST_VERSION_TWO):]
 
140
        else:
 
141
            protocol_class = protocol.SmartServerRequestProtocolOne
 
142
        server_protocol = protocol_class(transport, write_func)
 
143
        server_protocol.accept_bytes(request_bytes)
 
144
        return server_protocol