forked from openstack/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move cors-test-page to literal include
This makes it so test-cors.html is a real file in doc/source so it's easy for those in the know to jump in there with a `python -m SimpleHTTPServer` and point their webbrowser to `http://localhost:8000/test-cors.html`. The example html and javascript still appear in the docs in their entirety using the Sphinx literal include directive. Change-Id: Ia0ba36df6c58795e3764fa53b7f585dcc1b3be07
- Loading branch information
Showing
2 changed files
with
65 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test CORS</title> | ||
</head> | ||
<body> | ||
|
||
Token<br><input id="token" type="text" size="64"><br><br> | ||
|
||
Method<br> | ||
<select id="method"> | ||
<option value="GET">GET</option> | ||
<option value="HEAD">HEAD</option> | ||
<option value="POST">POST</option> | ||
<option value="DELETE">DELETE</option> | ||
<option value="PUT">PUT</option> | ||
</select><br><br> | ||
|
||
URL (Container or Object)<br><input id="url" size="64" type="text"><br><br> | ||
|
||
<input id="submit" type="button" value="Submit" onclick="submit(); return false;"> | ||
|
||
<pre id="response_headers"></pre> | ||
<p> | ||
<hr> | ||
<pre id="response_body"></pre> | ||
|
||
<script type="text/javascript"> | ||
function submit() { | ||
var token = document.getElementById('token').value; | ||
var method = document.getElementById('method').value; | ||
var url = document.getElementById('url').value; | ||
|
||
document.getElementById('response_headers').textContent = null; | ||
document.getElementById('response_body').textContent = null; | ||
|
||
var request = new XMLHttpRequest(); | ||
|
||
request.onreadystatechange = function (oEvent) { | ||
if (request.readyState == 4) { | ||
responseHeaders = 'Status: ' + request.status; | ||
responseHeaders = responseHeaders + '\nStatus Text: ' + request.statusText; | ||
responseHeaders = responseHeaders + '\n\n' + request.getAllResponseHeaders(); | ||
document.getElementById('response_headers').textContent = responseHeaders; | ||
document.getElementById('response_body').textContent = request.responseText; | ||
} | ||
} | ||
|
||
request.open(method, url); | ||
if (token != '') { | ||
// custom headers always trigger a pre-flight request | ||
request.setRequestHeader('X-Auth-Token', token); | ||
} | ||
request.send(null); | ||
} | ||
</script> | ||
|
||
</body> | ||
</html> |