fix-sse-protocol

This commit is contained in:
Untone 2023-10-19 12:16:08 +03:00
parent 6c0f84749e
commit bf442e01c9
2 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,3 @@
# sigil ver 2.2 dufok 2022-10-15 (with location /connect nobuffer)
# Proxy settings
{{ $proxy_settings := "proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_set_header Host $http_host; proxy_set_header X-Request-Start $msec;" }}
# GZIP settings

View File

@ -128,7 +128,10 @@ async fn connect_handler(
let server_event_stream = futures::stream::unfold(rx, |mut rx| async {
let result = rx.recv().await;
match result {
Ok(server_event) => Some((Ok::<_, actix_web::Error>(Bytes::from(server_event)), rx)),
Ok(server_event) => {
let formatted_server_event = format!("data: {}\n\n", server_event);
Some((Ok::<_, actix_web::Error>(Bytes::from(formatted_server_event)), rx))
},
Err(_) => None,
}
});