/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 bzrlib/tests/http_utils.py

  • Committer: Vincent Ladeuil
  • Date: 2011-06-07 11:11:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5962.
  • Revision ID: v.ladeuil+lp@free.fr-20110607111108-bt0ud8l7vrxlgib6
Allows HEAD to be used in tests while still requiring authentication.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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):