add missing corp/cache-control headers to authenticated media
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
fd11fee88d
commit
9d25b0d5c2
@ -9,12 +9,14 @@ pub mod v1 {
|
|||||||
|
|
||||||
use std::{borrow::Cow, time::Duration};
|
use std::{borrow::Cow, time::Duration};
|
||||||
|
|
||||||
use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE};
|
use http::header::{CACHE_CONTROL, CONTENT_DISPOSITION, CONTENT_TYPE};
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, IdParseError, MxcUri, OwnedServerName,
|
metadata, IdParseError, MxcUri, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: GET,
|
method: GET,
|
||||||
rate_limited: true,
|
rate_limited: true,
|
||||||
@ -68,6 +70,22 @@ pub mod v1 {
|
|||||||
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Syntax
|
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Syntax
|
||||||
#[ruma_api(header = CONTENT_DISPOSITION)]
|
#[ruma_api(header = CONTENT_DISPOSITION)]
|
||||||
pub content_disposition: Option<Cow<'static, str>>,
|
pub content_disposition: Option<Cow<'static, str>>,
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
#[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)]
|
||||||
|
pub cross_origin_resource_policy: Option<Cow<'static, str>>,
|
||||||
|
|
||||||
|
/// 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<Cow<'static, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
@ -87,7 +105,13 @@ pub mod v1 {
|
|||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given file contents.
|
/// Creates a new `Response` with the given file contents.
|
||||||
pub fn new(file: Vec<u8>) -> Self {
|
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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,14 @@ pub mod v1 {
|
|||||||
|
|
||||||
use std::{borrow::Cow, time::Duration};
|
use std::{borrow::Cow, time::Duration};
|
||||||
|
|
||||||
use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE};
|
use http::header::{CACHE_CONTROL, CONTENT_DISPOSITION, CONTENT_TYPE};
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, IdParseError, MxcUri, OwnedServerName,
|
metadata, IdParseError, MxcUri, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: GET,
|
method: GET,
|
||||||
rate_limited: true,
|
rate_limited: true,
|
||||||
@ -72,6 +74,22 @@ pub mod v1 {
|
|||||||
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Syntax
|
/// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Syntax
|
||||||
#[ruma_api(header = CONTENT_DISPOSITION)]
|
#[ruma_api(header = CONTENT_DISPOSITION)]
|
||||||
pub content_disposition: Option<Cow<'static, str>>,
|
pub content_disposition: Option<Cow<'static, str>>,
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
#[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)]
|
||||||
|
pub cross_origin_resource_policy: Option<Cow<'static, str>>,
|
||||||
|
|
||||||
|
/// 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<Cow<'static, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
@ -96,7 +114,13 @@ pub mod v1 {
|
|||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given file.
|
/// Creates a new `Response` with the given file.
|
||||||
pub fn new(file: Vec<u8>) -> Self {
|
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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,16 @@ pub mod v1 {
|
|||||||
|
|
||||||
use std::{borrow::Cow, time::Duration};
|
use std::{borrow::Cow, time::Duration};
|
||||||
|
|
||||||
use http::header::CONTENT_TYPE;
|
use http::header::{CACHE_CONTROL, CONTENT_TYPE};
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata, IdParseError, MxcUri, OwnedServerName,
|
metadata, IdParseError, MxcUri, OwnedServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::media::get_content_thumbnail::v3::Method;
|
use crate::{
|
||||||
|
http_headers::CROSS_ORIGIN_RESOURCE_POLICY, media::get_content_thumbnail::v3::Method,
|
||||||
|
};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: GET,
|
method: GET,
|
||||||
@ -88,6 +90,22 @@ pub mod v1 {
|
|||||||
/// The content type of the thumbnail.
|
/// The content type of the thumbnail.
|
||||||
#[ruma_api(header = CONTENT_TYPE)]
|
#[ruma_api(header = CONTENT_TYPE)]
|
||||||
pub content_type: Option<Cow<'static, str>>,
|
pub content_type: Option<Cow<'static, str>>,
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
#[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)]
|
||||||
|
pub cross_origin_resource_policy: Option<Cow<'static, str>>,
|
||||||
|
|
||||||
|
/// 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<Cow<'static, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
@ -122,7 +140,12 @@ pub mod v1 {
|
|||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given thumbnail.
|
/// Creates a new `Response` with the given thumbnail.
|
||||||
pub fn new(file: Vec<u8>) -> Self {
|
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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user