145
145
class HTTPServerRedirecting(http_server.HttpServer):
146
146
"""An HttpServer redirecting to another server """
148
def __init__(self, request_handler=RedirectRequestHandler):
149
http_server.HttpServer.__init__(self, request_handler)
148
def __init__(self, request_handler=RedirectRequestHandler,
149
protocol_version=None):
150
http_server.HttpServer.__init__(self, request_handler,
151
protocol_version=protocol_version)
150
152
# redirections is a list of tuples (source, target, code)
151
153
# - source is a regexp for the paths requested
152
154
# - target is a replacement for re.sub describing where
307
309
auth_error_code = None
308
310
auth_realm = "Thou should not pass"
310
def __init__(self, request_handler, auth_scheme):
311
http_server.HttpServer.__init__(self, request_handler)
312
def __init__(self, request_handler, auth_scheme,
313
protocol_version=None):
314
http_server.HttpServer.__init__(self, request_handler,
315
protocol_version=protocol_version)
312
316
self.auth_scheme = auth_scheme
313
317
self.password_of = {}
314
318
self.auth_required_errors = 0
338
342
auth_nonce = 'now!'
340
def __init__(self, request_handler, auth_scheme):
341
AuthServer.__init__(self, request_handler, auth_scheme)
344
def __init__(self, request_handler, auth_scheme,
345
protocol_version=None):
346
AuthServer.__init__(self, request_handler, auth_scheme,
347
protocol_version=protocol_version)
343
349
def digest_authorized(self, auth, command):
344
350
nonce = auth['nonce']
399
405
class HTTPBasicAuthServer(HTTPAuthServer):
400
406
"""An HTTP server requiring basic authentication"""
403
HTTPAuthServer.__init__(self, BasicAuthRequestHandler, 'basic')
408
def __init__(self, protocol_version=None):
409
HTTPAuthServer.__init__(self, BasicAuthRequestHandler, 'basic',
410
protocol_version=protocol_version)
404
411
self.init_http_auth()
407
414
class HTTPDigestAuthServer(DigestAuthServer, HTTPAuthServer):
408
415
"""An HTTP server requiring digest authentication"""
411
DigestAuthServer.__init__(self, DigestAuthRequestHandler, 'digest')
417
def __init__(self, protocol_version=None):
418
DigestAuthServer.__init__(self, DigestAuthRequestHandler, 'digest',
419
protocol_version=protocol_version)
412
420
self.init_http_auth()
415
423
class ProxyBasicAuthServer(ProxyAuthServer):
416
424
"""A proxy server requiring basic authentication"""
419
ProxyAuthServer.__init__(self, BasicAuthRequestHandler, 'basic')
426
def __init__(self, protocol_version=None):
427
ProxyAuthServer.__init__(self, BasicAuthRequestHandler, 'basic',
428
protocol_version=protocol_version)
420
429
self.init_proxy_auth()
423
432
class ProxyDigestAuthServer(DigestAuthServer, ProxyAuthServer):
424
433
"""A proxy server requiring basic authentication"""
427
ProxyAuthServer.__init__(self, DigestAuthRequestHandler, 'digest')
435
def __init__(self, protocol_version=None):
436
ProxyAuthServer.__init__(self, DigestAuthRequestHandler, 'digest',
437
protocol_version=protocol_version)
428
438
self.init_proxy_auth()