From a9bc07e98d64538e84e7659a481948d58b1eff1e Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Wed, 6 Dec 2023 06:39:18 +0000 Subject: [PATCH] Send 206 response in UMP response content. --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 95e143a..0fdfe42 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use actix_web::http::Method; +use actix_web::http::{Method, StatusCode}; use actix_web::{web, App, HttpRequest, HttpResponse, HttpResponseBuilder, HttpServer}; use once_cell::sync::Lazy; use qstring::QString; @@ -120,6 +120,7 @@ fn is_header_allowed(header: &str) -> bool { | "report-to" | "strict-transport-security" | "user-agent" + | "range" ) } @@ -244,6 +245,8 @@ async fn index(req: HttpRequest) -> Result> { } } + let has_range = query.has("range"); + let qs = { let collected = query .into_pairs() @@ -427,6 +430,9 @@ async fn index(req: HttpRequest) -> Result> { if let Some(mime_type) = mime_type { response.content_type(mime_type); } + if has_range { + response.status(StatusCode::PARTIAL_CONTENT); + } let transformed_stream = UmpTransformStream::new(resp); return Ok(response.streaming(transformed_stream)); }