proxied_request_check.html 778 B

1234567891011121314151617181920212223242526272829303132
  1. <!DOCTYPE html>
  2. <head>
  3. <title>test proxied ws connection</title>
  4. </head>
  5. <script type="text/javascript">
  6. // Do connection test and check the headers arrive at the WebSocket.
  7. var protocol = location.protocol.replace('http', 'ws');
  8. var url = protocol + '//' + location.host + '/echo-request-headers';
  9. var ws = new WebSocket(url);
  10. ws.onmessage = function(evt)
  11. {
  12. var headers = JSON.parse(evt.data);
  13. for (var name in headers) {
  14. // The keys in the serialized data are lower cased.
  15. if (name.startsWith('proxy-')) {
  16. document.title = 'FAIL';
  17. return;
  18. }
  19. }
  20. // Set document title to 'PASS'. The test observer catches this title changes
  21. // to know the result.
  22. document.title = 'PASS';
  23. }
  24. ws.onclose = function()
  25. {
  26. document.title = 'FAIL';
  27. }
  28. </script>