client-api: Add cache-control header to media responses.

This commit is contained in:
Jason Volk 2024-04-04 23:41:46 -07:00 committed by strawberry
parent 31851540e9
commit eb970d044d
3 changed files with 30 additions and 3 deletions

View File

@ -9,7 +9,7 @@ pub mod v3 {
use std::time::Duration;
use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE};
use http::header::{CACHE_CONTROL, CONTENT_DISPOSITION, CONTENT_TYPE};
use ruma_common::{
api::{request, response, Metadata},
metadata, IdParseError, MxcUri, OwnedServerName,
@ -96,6 +96,14 @@ pub mod v3 {
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
#[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)]
pub cross_origin_resource_policy: Option<String>,
/// The value of the `Cache-Control` HTTP header.
///
/// See [MDN] for the syntax.
///
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#syntax
#[ruma_api(header = CACHE_CONTROL)]
pub cache_control: Option<String>,
}
impl Request {
@ -128,6 +136,7 @@ pub mod v3 {
content_type: None,
content_disposition: None,
cross_origin_resource_policy: Some("cross-origin".to_owned()),
cache_control: None,
}
}
}

View File

@ -9,7 +9,7 @@ pub mod v3 {
use std::time::Duration;
use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE};
use http::header::{CACHE_CONTROL, CONTENT_DISPOSITION, CONTENT_TYPE};
use ruma_common::{
api::{request, response, Metadata},
metadata, IdParseError, MxcUri, OwnedServerName,
@ -100,6 +100,14 @@ pub mod v3 {
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
#[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)]
pub cross_origin_resource_policy: Option<String>,
/// The value of the `Cache-Control` HTTP header.
///
/// See [MDN] for the syntax.
///
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#syntax
#[ruma_api(header = CACHE_CONTROL)]
pub cache_control: Option<String>,
}
impl Request {
@ -133,6 +141,7 @@ pub mod v3 {
content_type: None,
content_disposition: None,
cross_origin_resource_policy: Some("cross-origin".to_owned()),
cache_control: None,
}
}
}

View File

@ -9,7 +9,7 @@ pub mod v3 {
use std::time::Duration;
use http::header::CONTENT_TYPE;
use http::header::{CACHE_CONTROL, CONTENT_TYPE};
use js_int::UInt;
use ruma_common::{
api::{request, response, Metadata},
@ -107,6 +107,14 @@ pub mod v3 {
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
#[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)]
pub cross_origin_resource_policy: Option<String>,
/// The value of the `Cache-Control` HTTP header.
///
/// See [MDN] for the syntax.
///
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#syntax
#[ruma_api(header = CACHE_CONTROL)]
pub cache_control: Option<String>,
}
impl Request {
@ -148,6 +156,7 @@ pub mod v3 {
file,
content_type: None,
cross_origin_resource_policy: Some("cross-origin".to_owned()),
cache_control: None,
}
}
}