add missing corp/cache-control headers to client authenticated media

Signed-off-by: Jason Volk <jason@zemos.net>
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
Jason Volk 2024-08-14 02:09:52 -04:00 committed by strawberry
parent 69b2bc4b8c
commit e312768a66
3 changed files with 89 additions and 6 deletions

View File

@ -9,13 +9,15 @@ pub mod v1 {
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},
http_headers::ContentDisposition,
metadata, IdParseError, MxcUri, OwnedServerName,
};
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
const METADATA: Metadata = metadata! {
method: GET,
rate_limited: true,
@ -65,6 +67,26 @@ pub mod v1 {
/// file that was previously uploaded.
#[ruma_api(header = CONTENT_DISPOSITION)]
pub content_disposition: Option<ContentDisposition>,
/// The value of the `Cross-Origin-Resource-Policy` HTTP header.
///
/// See [MDN] for the syntax.
///
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
///
/// TODO: make this use Cow static str's
#[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
///
/// TODO: make this use Cow static str's
#[ruma_api(header = CACHE_CONTROL)]
pub cache_control: Option<String>,
}
impl Request {
@ -88,7 +110,13 @@ pub mod v1 {
impl Response {
/// Creates a new `Response` with the given file contents.
pub fn new(file: Vec<u8>) -> Self {
Self { file, content_type: None, content_disposition: None }
Self {
file,
content_type: None,
content_disposition: None,
cross_origin_resource_policy: None,
cache_control: None,
}
}
}
}

View File

@ -9,13 +9,15 @@ pub mod v1 {
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},
http_headers::ContentDisposition,
metadata, IdParseError, MxcUri, OwnedServerName,
};
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
const METADATA: Metadata = metadata! {
method: GET,
rate_limited: true,
@ -69,6 +71,26 @@ pub mod v1 {
/// file that was previously uploaded.
#[ruma_api(header = CONTENT_DISPOSITION)]
pub content_disposition: Option<ContentDisposition>,
/// The value of the `Cross-Origin-Resource-Policy` HTTP header.
///
/// See [MDN] for the syntax.
///
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
///
/// TODO: make this use Cow static str's
#[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
///
/// TODO: make this use Cow static str's
#[ruma_api(header = CACHE_CONTROL)]
pub cache_control: Option<String>,
}
impl Request {
@ -93,7 +115,13 @@ pub mod v1 {
impl Response {
/// Creates a new `Response` with the given file.
pub fn new(file: Vec<u8>) -> Self {
Self { file, content_type: None, content_disposition: None }
Self {
file,
content_type: None,
content_disposition: None,
cross_origin_resource_policy: None,
cache_control: None,
}
}
}
}

View File

@ -9,7 +9,7 @@ pub mod v1 {
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},
@ -17,6 +17,8 @@ pub mod v1 {
metadata, IdParseError, MxcUri, OwnedServerName,
};
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
const METADATA: Metadata = metadata! {
method: GET,
rate_limited: true,
@ -87,6 +89,26 @@ pub mod v1 {
/// The content type of the thumbnail.
#[ruma_api(header = CONTENT_TYPE)]
pub content_type: Option<String>,
/// The value of the `Cross-Origin-Resource-Policy` HTTP header.
///
/// See [MDN] for the syntax.
///
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
///
/// TODO: make this use Cow static str's
#[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
///
/// TODO: make this use Cow static str's
#[ruma_api(header = CACHE_CONTROL)]
pub cache_control: Option<String>,
}
impl Request {
@ -121,7 +143,12 @@ pub mod v1 {
impl Response {
/// Creates a new `Response` with the given thumbnail.
pub fn new(file: Vec<u8>) -> Self {
Self { file, content_type: None }
Self {
file,
content_type: None,
cross_origin_resource_policy: None,
cache_control: None,
}
}
}
}