~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_utils.py

(gz) Fix test failure on alpha by correcting format string for
 gc_chk_sha1_record (Martin [gz])

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_from_path(
 
54
        backing = transport.get_transport(
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_from_url(chroot_server.get_url())
 
59
            t = transport.get_transport(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_from_url(self.get_secondary_url(relpath))
 
156
        t = transport.get_transport(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_from_url(self.get_old_url(relpath))
 
260
        t = transport.get_transport(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_from_url(self.get_new_url(relpath))
 
269
        t = transport.get_transport(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
 
 
300
287
    def do_GET(self):
301
288
        if self.authorized():
302
289
            return http_server.TestingHTTPRequestHandler.do_GET(self)
303
290
        else:
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()
 
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
311
302
 
312
303
 
313
304
class BasicAuthRequestHandler(AuthRequestHandler):