mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 15:48:49 -05:00
test1450: fix up DICT server in torture mode
As per https://github.com/curl/curl/pull/1615, the DICT server is a little spammy in torture mode due to the sockets being torn down unexpectedly. Fix this by adding some error handling to the handling function. Closes #1629
This commit is contained in:
parent
9b387034ab
commit
0362c77841
@ -52,34 +52,37 @@ class DictHandler(socketserver.BaseRequestHandler):
|
|||||||
"""
|
"""
|
||||||
Simple function which responds to all queries with a 552.
|
Simple function which responds to all queries with a 552.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
# First, send a response to allow the server to continue.
|
||||||
|
rsp = "220 dictserver <xnooptions> <msgid@msgid>\n"
|
||||||
|
self.request.sendall(rsp.encode("utf-8"))
|
||||||
|
|
||||||
# First, send a response to allow the server to continue.
|
# Receive the request.
|
||||||
rsp = "220 dictserver <xnooptions> <msgid@msgid>\n"
|
data = self.request.recv(1024).strip()
|
||||||
self.request.sendall(rsp.encode("utf-8"))
|
log.debug("[DICT] Incoming data: %r", data)
|
||||||
|
|
||||||
# Receive the request.
|
if VERIFIED_REQ in data:
|
||||||
data = self.request.recv(1024).strip()
|
log.debug("[DICT] Received verification request from test "
|
||||||
log.debug("[DICT] Incoming data: %r", data)
|
"framework")
|
||||||
|
response_data = VERIFIED_RSP.format(pid=os.getpid())
|
||||||
|
else:
|
||||||
|
log.debug("[DICT] Received normal request")
|
||||||
|
response_data = "No matches"
|
||||||
|
|
||||||
if VERIFIED_REQ in data:
|
# Send back a failure to find.
|
||||||
log.debug("[DICT] Received verification request from test "
|
response = "552 {0}\n".format(response_data)
|
||||||
"framework")
|
log.debug("[DICT] Responding with %r", response)
|
||||||
response_data = VERIFIED_RSP.format(pid=os.getpid())
|
self.request.sendall(response.encode("utf-8"))
|
||||||
else:
|
|
||||||
log.debug("[DICT] Received normal request")
|
|
||||||
response_data = "No matches"
|
|
||||||
|
|
||||||
# Send back a failure to find.
|
except IOError:
|
||||||
response = "552 {0}\n".format(response_data)
|
log.exception("[DICT] IOError hit during request")
|
||||||
log.debug("[DICT] Responding with %r", response)
|
|
||||||
self.request.sendall(response.encode("utf-8"))
|
|
||||||
|
|
||||||
|
|
||||||
def get_options():
|
def get_options():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
parser.add_argument("--port", action="store", default=9016,
|
parser.add_argument("--port", action="store", default=9016,
|
||||||
type=int, help="port to listen on")
|
type=int, help="port to listen on")
|
||||||
parser.add_argument("--verbose", action="store", type=int, default=0,
|
parser.add_argument("--verbose", action="store", type=int, default=0,
|
||||||
help="verbose output")
|
help="verbose output")
|
||||||
parser.add_argument("--pidfile", action="store",
|
parser.add_argument("--pidfile", action="store",
|
||||||
|
Loading…
Reference in New Issue
Block a user