Skip to content

Commit

Permalink
Python self-hosting: Review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
odinho committed Dec 18, 2013
1 parent a7dde5f commit f16bef0
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
9 changes: 6 additions & 3 deletions XMLHttpRequest/resources/authentication.py
Expand Up @@ -12,7 +12,7 @@ def main(request, response):
token = expected_user_name
if session_user is None and session_pass is None:
if token is not None and request.server.stash.take(token) is not None:
return 'FAIL (did not challenge)'
return 'FAIL (did not authorize)'
else:
if token is not None:
request.server.stash.put(token, "1")
Expand All @@ -22,9 +22,12 @@ def main(request, response):
('SES-USER', session_user)]
return status, headers, 'FAIL (should be transparent)'
else:
if request.server.stash.take(token) == "1":
challenge = "DID"
else:
challenge = "DID-NOT"
headers = [('XHR-USER', expected_user_name),
('SES-USER', session_user),
("X-challenge", "DID" if token is not None and request.server.stash.take(token) is None
else "DID-NOT")]
("X-challenge", challenge)]
return headers, session_user + "\n" + session_pass;

2 changes: 1 addition & 1 deletion XMLHttpRequest/resources/corsenabled.py
Expand Up @@ -14,6 +14,6 @@ def main(request, response):
headers.append(("X-Request-Method", request.method))
headers.append(("X-Request-Query", request.url_parts.query if request.url_parts.query else "NO"))
headers.append(("X-Request-Content-Length", request.headers.get("Content-Length", "NO")))
headers.append(("X-Request-Content-Type", request.headers.get("Content-Type" "NO")))
headers.append(("X-Request-Content-Type", request.headers.get("Content-Type", "NO")))

return headers, "Test"
2 changes: 1 addition & 1 deletion XMLHttpRequest/resources/form.py
@@ -1,2 +1,2 @@
def main(request, response):
return "id:%s;value:%s;" % (request.GET.first("id"), request.GET.first("value"))
return "id:%s;value:%s;" % (request.POST.first("id"), request.POST.first("value"))
2 changes: 1 addition & 1 deletion XMLHttpRequest/resources/redirect.py
Expand Up @@ -2,7 +2,7 @@ def main(request, response):
code = int(request.GET.first("code", 302))
location = request.GET.first("location", request.url_parts.path +"?followed")

if "followed" in server.query:
if request.url.endswith("?followed"):
return [("Content:Type", "text/plain")], "MAGIC HAPPENED"
else:
return (code, "WEBSRT MARKETING"), [("Location", location)], "TEST"
2 changes: 1 addition & 1 deletion XMLHttpRequest/response-data-blob.htm
Expand Up @@ -27,7 +27,7 @@
test.step(function()
{
blob = xhr.response;
assert_true(blob instanceof Blob);
assert_true(blob instanceof Blob, 'blob is a Blob');

var reader = new FileReader();
reader.onload = function()
Expand Down
4 changes: 2 additions & 2 deletions XMLHttpRequest/send-accept-language.htm
Expand Up @@ -17,10 +17,10 @@
}, 'Send "sensible" default value, whatever that means')
test(function() {
var client = new XMLHttpRequest()
client.open("GET", "resources/accept-language.py", false)
client.open("GET", "resources/inspect-headers.py?filter_name=accept-language", false)
client.setRequestHeader("Accept-Language", "x-GameSpeak")
client.send(null)
assert_equals(client.responseText, "x-GameSpeak")
assert_regexp_match(client.responseText, /accept-language:\sx-GameSpeak/)
})
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion XMLHttpRequest/send-redirect-to-cors.htm
Expand Up @@ -22,7 +22,7 @@
}
})
}
client.open("GET", "resources/redirect.py?location="+encodeURIComponent("http://www2."+location.hostname+(location.pathname.replace(/[^\/]+$/, ''))+'resources/corsenabled.py')+"&code=" + code)
client.open("GET", "resources/redirect.py?location="+encodeURIComponent("http://www2."+location.host+(location.pathname.replace(/[^\/]+$/, ''))+'resources/corsenabled.py')+"&code=" + code)
client.setRequestHeader("Content-Type", "application/x-pony")
client.send(null)
})
Expand Down

0 comments on commit f16bef0

Please sign in to comment.