mirror of
https://github.com/mirror/wget.git
synced 2024-12-28 05:40:08 +08:00
Use the provided calls to shutdown server instead of rewriting it
This commit is contained in:
parent
99659f3295
commit
e84192a8d3
@ -1,3 +1,14 @@
|
||||
2013-09-10 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* WgetTest.py (HTTPTest.stop_HTTP_server): With the threaded servers,
|
||||
we can simply use the socketserver.shutdown() method to close the
|
||||
server instead of sending a QUIT command
|
||||
* HTTPServer.py (StoppabelHTTPServer.serve_forever): Delete method. No
|
||||
need to override this method anymore.
|
||||
(WgetHTTPRequestHandler.do_QUIT): No longer required
|
||||
(HTTPd): Rename self.server to self.server_inst to reduce ambiguity
|
||||
when referenced from WgetTest
|
||||
|
||||
2013-09-08 Darshit Shah <darnir@gmail.com>
|
||||
|
||||
* README (File Structure): Add explanation about various variables
|
||||
|
@ -3,7 +3,6 @@ from base64 import b64encode
|
||||
from random import random
|
||||
from hashlib import md5
|
||||
import threading
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
@ -29,11 +28,6 @@ class StoppableHTTPServer (HTTPServer):
|
||||
self.server_configs = conf_dict
|
||||
self.fileSys = filelist
|
||||
|
||||
def serve_forever (self):
|
||||
self.stop = False
|
||||
while not self.stop:
|
||||
self.handle_request ()
|
||||
|
||||
|
||||
class WgetHTTPRequestHandler (BaseHTTPRequestHandler):
|
||||
|
||||
@ -43,11 +37,6 @@ class WgetHTTPRequestHandler (BaseHTTPRequestHandler):
|
||||
r_list = self.rules.get (name) if name in self.rules else None
|
||||
return r_list
|
||||
|
||||
def do_QUIT (self):
|
||||
self.send_response (200)
|
||||
self.end_headers ()
|
||||
self.server.stop = True
|
||||
|
||||
|
||||
class _Handler (WgetHTTPRequestHandler):
|
||||
|
||||
@ -394,13 +383,13 @@ class HTTPd (threading.Thread):
|
||||
threading.Thread.__init__ (self)
|
||||
if addr is None:
|
||||
addr = ('localhost', 0)
|
||||
self.server = self.server_class (addr, self.handler)
|
||||
self.server_address = self.server.socket.getsockname()[:2]
|
||||
self.server_inst = self.server_class (addr, self.handler)
|
||||
self.server_address = self.server_inst.socket.getsockname()[:2]
|
||||
|
||||
def run (self):
|
||||
self.server.serve_forever ()
|
||||
self.server_inst.serve_forever ()
|
||||
|
||||
def server_conf (self, file_list, server_rules):
|
||||
self.server.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 :
|
||||
|
@ -4,7 +4,6 @@ import shlex
|
||||
import sys
|
||||
import traceback
|
||||
import HTTPServer
|
||||
import http.client
|
||||
import re
|
||||
from subprocess import call
|
||||
from ColourTerm import printer
|
||||
@ -254,9 +253,7 @@ class HTTPTest (CommonMethods):
|
||||
return server
|
||||
|
||||
def stop_HTTP_Server (self):
|
||||
conn = http.client.HTTPConnection (self.domain.strip ('/'))
|
||||
conn.request ("QUIT", "/")
|
||||
conn.getresponse ()
|
||||
self.server.server_inst.shutdown ()
|
||||
|
||||
""" WgetFile is a File Data Container object """
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user