69
70
# fingerprint. Let's glob.
70
71
if suffix.startswith('0x'):
71
72
suffix = suffix[2:]
72
keys = glob.glob(os.path.join(root, '*'+suffix))
73
keys = glob.glob(os.path.join(root, '*' + suffix))
127
134
return 'Invalid Arguments %s' % request.args
129
return self.processRequest(action, keyid)
136
return self.processRequest(action, keyid, request)
131
def processRequest(self, action, keyid):
138
def processRequest(self, action, keyid, request):
139
# Sleep a short time so that tests can ensure that timeouts
140
# are properly handled by setting an even shorter timeout.
132
142
if (action not in self.permitted_actions) or not keyid:
133
143
return 'Forbidden: "%s" on ID "%s"' % (action, keyid)
135
page = ('<html>\n<head>\n'
136
'<title>Results for Key %s</title>\n'
138
'<h1>Results for Key %s</h1>\n'
141
145
filename = '%s.%s' % (keyid, action)
143
147
path = locate_key(self.root, filename)
144
148
if path is not None:
145
149
content = cgi.escape(open(path).read())
150
page = ('<html>\n<head>\n'
151
'<title>Results for Key %s</title>\n'
153
'<h1>Results for Key %s</h1>\n'
154
'<pre>\n%s\n</pre>\n</html>') % (keyid, keyid, content)
147
content = 'Key Not Found'
149
page += '<pre>\n%s\n</pre>\n</html>' % content
157
# No joke: our real-world keyserver returns a 500 error
158
# if it does not know about a key with the given ID.
159
request.setResponseCode(500)
160
return KEY_NOT_FOUND_BODY
154
163
SUBMIT_KEY_PAGE = """