[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] Make URL-based registration work with HEAD as well as GET.
commit 370a2650d406f3b1b2029f54b174f7e24446b61a
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Wed Mar 13 02:24:05 2013 -0700
Make URL-based registration work with HEAD as well as GET.
---
facilitator/facilitator.cgi | 33 +++++++++++++++++++++++----------
1 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/facilitator/facilitator.cgi b/facilitator/facilitator.cgi
index bb0ac51..4885ead 100755
--- a/facilitator/facilitator.cgi
+++ b/facilitator/facilitator.cgi
@@ -21,7 +21,7 @@ def exit_error(status):
sys.exit()
# Send a base64-encoded client address to the registration daemon.
-def url_reg(reg):
+def send_url_reg(reg):
# Translate from url-safe base64 alphabet to the standard alphabet.
reg = reg.replace('-', '+').replace('_', '/')
return fac.put_reg_base64(reg)
@@ -35,17 +35,28 @@ if not method or not remote_addr[0]:
fs = cgi.FieldStorage()
+# Print the HEAD part of a URL-based registration response, or exit with an
+# error if appropriate.
+def url_reg(reg):
+ try:
+ if send_url_reg(reg):
+ output_status(204)
+ else:
+ exit_error(400)
+ except:
+ exit_error(500)
+
+def do_head():
+ path_parts = [x for x in path_info.split("/") if x]
+ if len(path_parts) == 2 and path_parts[0] == "reg":
+ url_reg(path_parts[1])
+ else:
+ exit_error(400)
+
def do_get():
path_parts = [x for x in path_info.split("/") if x]
if len(path_parts) == 2 and path_parts[0] == "reg":
- # This is a URL-based registration.
- try:
- if url_reg(path_parts[1]):
- output_status(204)
- else:
- exit_error(400)
- except:
- exit_error(500)
+ url_reg(path_parts[1])
elif len(path_parts) == 0:
try:
reg = fac.get_reg(FACILITATOR_ADDR, remote_addr) or ""
@@ -79,7 +90,9 @@ def do_post():
Status: 200\r
\r"""
-if method == "GET":
+if method == "HEAD":
+ do_head()
+elif method == "GET":
do_get()
elif method == "POST":
do_post()
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits