Skip to content

Commit

Permalink
Merge "move cors-test-page to literal include"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Mar 20, 2014
2 parents 7829ca0 + 6514a48 commit 04de986
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 62 deletions.
67 changes: 5 additions & 62 deletions doc/source/cors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,71 +79,14 @@ something went wrong the response status will be 0.

.. _test CORS page:

--------------
Test CORS Page
--------------

::

<!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>
A sample cross-site test page is located in the project source tree
``doc/source/test-cors.html``.

.. literalinclude:: test-cors.html

.. _CORS: https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
.. _preflight request: https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS#Preflighted_requests
60 changes: 60 additions & 0 deletions doc/source/test-cors.html
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>

0 comments on commit 04de986

Please sign in to comment.