[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] Use cgi.FieldStorage for parsing postdata.
commit dd7cfb9c0c32b839287ffefe5bc2527009cd99f9
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Fri Jun 10 05:58:55 2011 -0700
Use cgi.FieldStorage for parsing postdata.
---
facilitator.py | 20 +++++++-------------
1 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/facilitator.py b/facilitator.py
index 7fc9484..801d0ad 100755
--- a/facilitator.py
+++ b/facilitator.py
@@ -219,29 +219,23 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
self.send_client(None)
def do_POST(self):
- data = self.rfile.readline(1024).strip()
- try:
- vals = cgi.parse_qs(data, False, True)
- except ValueError, e:
- self.send_error(400)
- log(u"client %s POST syntax error: %s" % (format_addr(self.client_address), repr(str(e))))
- return
+ data = cgi.FieldStorage(fp = self.rfile, headers = self.headers,
+ environ = {"REQUEST_METHOD": "POST"})
- client_specs = vals.get("client")
- if client_specs is None or len(client_specs) != 1:
+ client_spec = data.getfirst("client")
+ if client_spec is None:
self.send_error(400)
log(u"client %s missing \"client\" param" % format_addr(self.client_address))
return
- val = client_specs[0]
try:
- reg = Reg.parse(val, self.client_address[0])
+ reg = Reg.parse(client_spec, self.client_address[0])
except ValueError, e:
self.send_error(400)
- log(u"client %s syntax error in %s: %s" % (format_addr(self.client_address), repr(val), repr(str(e))))
+ log(u"client %s syntax error in %s: %s" % (format_addr(self.client_address), repr(client_spec), repr(str(e))))
return
- log(u"client %s regs %s -> %s" % (format_addr(self.client_address), val, unicode(reg)))
+ log(u"client %s regs %s -> %s" % (format_addr(self.client_address), client_spec, unicode(reg)))
if REGS.add(reg):
log(u"client %s %s (now %d)" % (format_addr(self.client_address), unicode(reg), len(REGS)))
else:
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits