mirror of
https://github.com/mirror/wget.git
synced 2025-03-13 11:20:19 +08:00
Support programatically setting Handler class variables
This commit is contained in:
parent
7e1f4c1abc
commit
7effa90359
@ -1,3 +1,12 @@
|
|||||||
|
2013-12-27 Darshit Shah <darnir@gmail.com>
|
||||||
|
|
||||||
|
* WgetTest.py: Add modeline
|
||||||
|
(CommonMethods.ServerConf): New pre-test hook that sets
|
||||||
|
BaseHTTPRequestHandler class variables in all available servers
|
||||||
|
* HTTPServer.py (HTTPd.ServerConf): Call the respective method in the Server
|
||||||
|
to set the class variables
|
||||||
|
(StoppableHTTPServer.server_sett): Set the handler class variables
|
||||||
|
|
||||||
2013-12-26 Darshit Shah <darnir@gmail.com>
|
2013-12-26 Darshit Shah <darnir@gmail.com>
|
||||||
|
|
||||||
* WgetTest.py (HTTPTest.call_test): Correct the call to stop_HTTP_Server.
|
* WgetTest.py (HTTPTest.call_test): Correct the call to stop_HTTP_Server.
|
||||||
|
@ -31,6 +31,10 @@ class StoppableHTTPServer (HTTPServer):
|
|||||||
self.server_configs = conf_dict
|
self.server_configs = conf_dict
|
||||||
self.fileSys = filelist
|
self.fileSys = filelist
|
||||||
|
|
||||||
|
def server_sett (self, settings):
|
||||||
|
for settings_key in settings:
|
||||||
|
setattr (self.RequestHandlerClass, settings_key, settings[settings_key])
|
||||||
|
|
||||||
def get_req_headers (self):
|
def get_req_headers (self):
|
||||||
return self.request_headers
|
return self.request_headers
|
||||||
|
|
||||||
@ -264,8 +268,13 @@ class _Handler (WgetHTTPRequestHandler):
|
|||||||
auth_type = auth_header.split(' ')[0] if auth_header else required_auth
|
auth_type = auth_header.split(' ')[0] if auth_header else required_auth
|
||||||
else:
|
else:
|
||||||
auth_type = required_auth
|
auth_type = required_auth
|
||||||
assert hasattr (self, "authorize_" + auth_type)
|
try:
|
||||||
is_auth = getattr (self, "authorize_" + auth_type) (auth_header, auth_rule)
|
assert hasattr (self, "authorize_" + auth_type)
|
||||||
|
is_auth = getattr (self, "authorize_" + auth_type) (auth_header, auth_rule)
|
||||||
|
except AssertionError:
|
||||||
|
raise ServerError ("Authentication Mechanism " + auth_rule + " not supported")
|
||||||
|
except AttributeError as ae:
|
||||||
|
raise ServerError (ae.__str__())
|
||||||
if is_auth is False:
|
if is_auth is False:
|
||||||
raise ServerError ("Unable to Authenticate")
|
raise ServerError ("Unable to Authenticate")
|
||||||
|
|
||||||
@ -427,4 +436,7 @@ class HTTPd (threading.Thread):
|
|||||||
def server_conf (self, file_list, server_rules):
|
def server_conf (self, file_list, server_rules):
|
||||||
self.server_inst.server_conf (file_list, server_rules)
|
self.server_inst.server_conf (file_list, server_rules)
|
||||||
|
|
||||||
# vim: set ts=8 sts=4 sw=3 tw=0 et :
|
def server_sett (self, settings):
|
||||||
|
self.server_inst.server_sett (settings)
|
||||||
|
|
||||||
|
# vim: set ts=4 sts=4 sw=4 tw=80 et :
|
||||||
|
@ -178,6 +178,10 @@ class CommonMethods:
|
|||||||
file_handler.write (file_obj.content)
|
file_handler.write (file_obj.content)
|
||||||
file_handler.close ()
|
file_handler.close ()
|
||||||
|
|
||||||
|
def ServerConf (self, server_settings):
|
||||||
|
for i in range (0, self.servers):
|
||||||
|
self.server_list[i].server_sett (server_settings)
|
||||||
|
|
||||||
""" Test Option Function Calls """
|
""" Test Option Function Calls """
|
||||||
|
|
||||||
def WgetCommands (self, command_list):
|
def WgetCommands (self, command_list):
|
||||||
@ -316,3 +320,5 @@ class WgetFile:
|
|||||||
self.content = content
|
self.content = content
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
self.rules = rules
|
self.rules = rules
|
||||||
|
|
||||||
|
# vim: set ts=4 sts=4 sw=4 tw=80 et :
|
||||||
|
Loading…
Reference in New Issue
Block a user