xref: /aosp_15_r20/external/cronet/net/data/websocket/proxied_request_check.html (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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
8var protocol = location.protocol.replace('http', 'ws');
9var url = protocol + '//' + location.host + '/echo-request-headers';
10var ws = new WebSocket(url);
11
12ws.onmessage = function(evt)
13{
14  var headers = JSON.parse(evt.data);
15  for (var name in headers) {
16    // The keys in the serialized data are lower cased.
17    if (name.startsWith('proxy-')) {
18      document.title = 'FAIL';
19      return;
20    }
21  }
22
23  // Set document title to 'PASS'. The test observer catches this title changes
24  // to know the result.
25  document.title = 'PASS';
26}
27
28ws.onclose = function()
29{
30  document.title = 'FAIL';
31}
32</script>
33