~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_utils.py

  • Committer: Patch Queue Manager
  • Date: 2014-04-09 13:36:25 UTC
  • mfrom: (6592.1.2 1303879-py27-issues)
  • Revision ID: pqm@pqm.ubuntu.com-20140409133625-s24spv3kha2w2860
(vila) Fix python-2.7.6 test failures. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
    def do_POST(self):
53
53
        """Hand the request off to a smart server instance."""
54
 
        backing = transport.get_transport(
 
54
        backing = transport.get_transport_from_path(
55
55
            self.server.test_case_server._home_dir)
56
56
        chroot_server = chroot.ChrootServer(backing)
57
57
        chroot_server.start_server()
58
58
        try:
59
 
            t = transport.get_transport(chroot_server.get_url())
 
59
            t = transport.get_transport_from_url(chroot_server.get_url())
60
60
            self.do_POST_inner(t)
61
61
        finally:
62
62
            chroot_server.stop_server()
153
153
        return self._adjust_url(base, relpath)
154
154
 
155
155
    def get_secondary_transport(self, relpath=None):
156
 
        t = transport.get_transport(self.get_secondary_url(relpath))
 
156
        t = transport.get_transport_from_url(self.get_secondary_url(relpath))
157
157
        self.assertTrue(t.is_readonly())
158
158
        return t
159
159
 
257
257
        return self._adjust_url(base, relpath)
258
258
 
259
259
   def get_old_transport(self, relpath=None):
260
 
        t = transport.get_transport(self.get_old_url(relpath))
 
260
        t = transport.get_transport_from_url(self.get_old_url(relpath))
261
261
        self.assertTrue(t.is_readonly())
262
262
        return t
263
263
 
266
266
        return self._adjust_url(base, relpath)
267
267
 
268
268
   def get_new_transport(self, relpath=None):
269
 
        t = transport.get_transport(self.get_new_url(relpath))
 
269
        t = transport.get_transport_from_url(self.get_new_url(relpath))
270
270
        self.assertTrue(t.is_readonly())
271
271
        return t
272
272
 
284
284
    # - auth_header_recv: the header received containing auth
285
285
    # - auth_error_code: the error code to indicate auth required
286
286
 
 
287
    def _require_authentication(self):
 
288
        # Note that we must update test_case_server *before*
 
289
        # sending the error or the client may try to read it
 
290
        # before we have sent the whole error back.
 
291
        tcs = self.server.test_case_server
 
292
        tcs.auth_required_errors += 1
 
293
        self.send_response(tcs.auth_error_code)
 
294
        self.send_header_auth_reqed()
 
295
        # We do not send a body
 
296
        self.send_header('Content-Length', '0')
 
297
        self.end_headers()
 
298
        return
 
299
 
287
300
    def do_GET(self):
288
301
        if self.authorized():
289
302
            return http_server.TestingHTTPRequestHandler.do_GET(self)
290
303
        else:
291
 
            # Note that we must update test_case_server *before*
292
 
            # sending the error or the client may try to read it
293
 
            # before we have sent the whole error back.
294
 
            tcs = self.server.test_case_server
295
 
            tcs.auth_required_errors += 1
296
 
            self.send_response(tcs.auth_error_code)
297
 
            self.send_header_auth_reqed()
298
 
            # We do not send a body
299
 
            self.send_header('Content-Length', '0')
300
 
            self.end_headers()
301
 
            return
 
304
            return self._require_authentication()
 
305
 
 
306
    def do_HEAD(self):
 
307
        if self.authorized():
 
308
            return http_server.TestingHTTPRequestHandler.do_HEAD(self)
 
309
        else:
 
310
            return self._require_authentication()
302
311
 
303
312
 
304
313
class BasicAuthRequestHandler(AuthRequestHandler):