Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
🥺
conduwuit
Commits
b3984f53
Commit
b3984f53
authored
10 months ago
by
Jason Volk
Committed by
🥺
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
deduplicate cache control into constant
Signed-off-by:
Jason Volk
<
jason@zemos.net
>
parent
7e5ed199
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/api/client_server/media.rs
+7
-4
7 additions, 4 deletions
src/api/client_server/media.rs
with
7 additions
and
4 deletions
src/api/client_server/media.rs
+
7
−
4
View file @
b3984f53
...
...
@@ -21,6 +21,9 @@
/// generated MXC ID (`media-id`) length
const
MXC_LENGTH
:
usize
=
32
;
/// Cache control for immutable objects
const
CACHE_CONTROL_IMMUTABLE
:
&
str
=
"public, max-age=31536000, immutable"
;
/// # `GET /_matrix/media/v3/config`
///
/// Returns max upload size.
...
...
@@ -175,7 +178,7 @@ pub(crate) async fn get_content_route(body: Ruma<get_content::v3::Request>) -> R
content_type
,
content_disposition
,
cross_origin_resource_policy
:
Some
(
"cross-origin"
.to_owned
()),
cache_control
:
Some
(
"public, max-age=31536000, immutable"
.to_owned
()),
cache_control
:
Some
(
CACHE_CONTROL_IMMUTABLE
.into
()),
})
}
else
if
&*
body
.server_name
!=
services
()
.globals
.server_name
()
&&
body
.allow_remote
{
let
remote_content_response
=
get_remote_content
(
...
...
@@ -234,7 +237,7 @@ pub(crate) async fn get_content_as_filename_route(
content_type
,
content_disposition
:
Some
(
format!
(
"inline; filename={}"
,
body
.filename
)),
cross_origin_resource_policy
:
Some
(
"cross-origin"
.to_owned
()),
cache_control
:
Some
(
"public, max-age=31536000, immutable"
.to_owned
()),
cache_control
:
Some
(
CACHE_CONTROL_IMMUTABLE
.into
()),
})
}
else
if
&*
body
.server_name
!=
services
()
.globals
.server_name
()
&&
body
.allow_remote
{
let
remote_content_response
=
get_remote_content
(
...
...
@@ -251,7 +254,7 @@ pub(crate) async fn get_content_as_filename_route(
content_type
:
remote_content_response
.content_type
,
file
:
remote_content_response
.file
,
cross_origin_resource_policy
:
Some
(
"cross-origin"
.to_owned
()),
cache_control
:
Some
(
"public, max-age=31536000, immutable"
.to_owned
()),
cache_control
:
Some
(
CACHE_CONTROL_IMMUTABLE
.into
()),
})
}
else
{
Err
(
Error
::
BadRequest
(
ErrorKind
::
NotFound
,
"Media not found."
))
...
...
@@ -310,7 +313,7 @@ pub(crate) async fn get_content_thumbnail_route(
file
,
content_type
,
cross_origin_resource_policy
:
Some
(
"cross-origin"
.to_owned
()),
cache_control
:
Some
(
"public, max-age=31536000, immutable"
.to_owned
()),
cache_control
:
Some
(
CACHE_CONTROL_IMMUTABLE
.into
()),
})
}
else
if
&*
body
.server_name
!=
services
()
.globals
.server_name
()
&&
body
.allow_remote
{
// we'll lie to the client and say the blocked server's media was not found and
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment