uce/test/websockets.ws.uce
udo cd8f07aaa7 Refactor FastCGI server and compiler, enhance HTTP header parsing, and add WebSocket support
- Refactored FastCGIServer class to improve socket handling and added shutdown functionality.
- Updated compiler functions to streamline HTML and text literal processing.
- Enhanced split_kv function to support uppercase keys and added split_http_headers for better HTTP header parsing.
- Introduced new session management functions to validate and handle session IDs.
- Added WebSocket frame parsing and handling in the URI module.
- Created systemd service scripts for easier deployment and management of the UCE FastCGI runtime.
- Added new test cases for header handling, time parsing, and WebSocket functionality.
2026-04-18 14:04:58 +00:00

43 lines
1.2 KiB
Plaintext

RENDER()
{
String raw = first(context->post["raw"], "today");
String server_url = context->params["HTTP_HOST"]+context->params["DOCUMENT_URI"];
<>
<link rel="stylesheet" href='style.css'></link>
<h1>
<a href="index.uce">UCE Test</a>:
WebSocket Test
</h1>
<form action="?" method="post">
<div>
<label></label>
<input type="text" name="raw" value="<?= raw ?>"/>
</div>
<div>
<input type="submit" value="Parse"/>
</div>
</form>
<pre id="log"></pre>
<script>
const ws = new WebSocket('wss://<?= server_url ?>');
const log_element = document.getElementById('log');
log_element.append('Connecting to wss://<?= server_url ?>...' + "\n");
ws.addEventListener('open', (event) => {
log_element.append('Connection open' + "\n");
ws.send('Hello, server!');
});
ws.addEventListener('message', (event) => {
log_element.append('Message: ' + JSON.stringify(event.data) + "\n");
});
ws.addEventListener('close', (event) => {
log_element.append('Connection closed' + "\n");
});
ws.addEventListener('error', (event) => {
log_element.append('Error: ' + JSON.stringify(event) + "\n");
});
</script>
<pre><?= var_dump(context->params) ?></pre>
</>
}