diff --git a/src/filters/sse.rs b/src/filters/sse.rs index 262448a6..4fcb9965 100644 --- a/src/filters/sse.rs +++ b/src/filters/sse.rs @@ -315,7 +315,10 @@ where S: TryStream + Send + 'static, S::Error: StdError + Send + Sync + 'static, { - SseReply { event_stream, charset: None } + SseReply { + event_stream, + charset: None, + } } /// Server-sent events reply (with explicit charset) @@ -400,13 +403,16 @@ where S: TryStream + Send + 'static, S::Error: StdError + Send + Sync + 'static, { - SseReply { event_stream, charset: Some(charset) } + SseReply { + event_stream, + charset: Some(charset), + } } #[allow(missing_debug_implementations)] struct SseReply { event_stream: S, - charset: Option + charset: Option, } impl Reply for SseReply @@ -428,11 +434,16 @@ where let mut res = Response::new(Body::wrap_stream(body_stream)); // Set appropriate content type - res.headers_mut() - .insert(CONTENT_TYPE, match self.charset { + res.headers_mut().insert( + CONTENT_TYPE, + match self.charset { None => HeaderValue::from_static("text/event-stream"), - Some(charset) => HeaderValue::from_str(format!("text/event-stream; charset={}", charset).as_str()).expect("Invalid header value"), - }); + Some(charset) => HeaderValue::from_str( + format!("text/event-stream; charset={}", charset).as_str(), + ) + .expect("Invalid header value"), + }, + ); // Disable response body caching res.headers_mut() .insert(CACHE_CONTROL, HeaderValue::from_static("no-cache"));