Skip to content

Commit

Permalink
Send 206 response in UMP response content.
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMasterK committed Dec 6, 2023
1 parent b9c8dc8 commit a9bc07e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -120,6 +120,7 @@ fn is_header_allowed(header: &str) -> bool {
| "report-to"
| "strict-transport-security"
| "user-agent"
| "range"
)
}

Expand Down Expand Up @@ -244,6 +245,8 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
}
}

let has_range = query.has("range");

let qs = {
let collected = query
.into_pairs()
Expand Down Expand Up @@ -427,6 +430,9 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
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));
}
Expand Down

0 comments on commit a9bc07e

Please sign in to comment.