Add Last Modified Header to npdi
All checks were successful
Build and Test / rust-boss (push) Successful in 7m15s
All checks were successful
Build and Test / rust-boss (push) Successful in 7m15s
This commit is contained in:
parent
1f27b24f1e
commit
af5af13c2a
1 changed files with 7 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use std::io::Cursor;
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use rocket::http::{Header, Status};
|
||||
use rocket::{Data, State};
|
||||
use rocket::response::{Response, Responder};
|
||||
|
|
@ -14,16 +15,20 @@ pub struct DataResponder<T> {
|
|||
content_disposition_header: Header<'static>,
|
||||
content_transfer_encoding_header: Header<'static>,
|
||||
content_length_header: Header<'static>,
|
||||
last_modified_header: Header<'static>,
|
||||
}
|
||||
|
||||
impl<'r, 'o: 'r, T: Responder<'r, 'o>> DataResponder<T> {
|
||||
fn new(inner: T, content_length: String) -> Self {
|
||||
fn new(inner: T, content_length: String, updated: NaiveDateTime) -> Self {
|
||||
let updated_utc: DateTime<Utc> = DateTime::from_naive_utc_and_offset(updated, Utc);
|
||||
|
||||
DataResponder {
|
||||
inner,
|
||||
content_type_header: Header::new("Content-Type", "applicatoin/octet-stream"), // Intentional spelling mistake
|
||||
content_disposition_header: Header::new("Content-Disposition", "attachment"),
|
||||
content_transfer_encoding_header: Header::new("Content-Transfer-Encoding", "binary"),
|
||||
content_length_header: Header::new("Content-Length", content_length),
|
||||
last_modified_header: Header::new("Last-Modified", updated_utc.format("%a, %d %b %Y %H:%M:%S GMT").to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -61,5 +66,5 @@ pub async fn data(pool: &State<Pool>, s3: &State<S3Client>,boss_app_id: String,
|
|||
.into_bytes()
|
||||
.to_vec();
|
||||
|
||||
Ok(DataResponder::new(data, file_wup.size.to_string()))
|
||||
Ok(DataResponder::new(data, file_wup.size.to_string(), file_wup.updated))
|
||||
}
|
||||
Loading…
Reference in a new issue