Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Desktop
Commits
1842af5d
Commit
1842af5d
authored
Feb 09, 2022
by
Dan Leinir Turthra Jensen
🌈
Committed by
Aleix Pol Gonzalez
Feb 19, 2022
Browse files
Only trust the expiration date if it's less than 24 hours
parent
c4aecfa6
Changes
1
Hide whitespace changes
Inline
Side-by-side
attica-kde/kdeplugin/kdeplatformdependent.cpp
View file @
1842af5d
...
...
@@ -133,7 +133,16 @@ QNetworkRequest KdePlatformDependent::addOAuthToRequest(const QNetworkRequest &r
}
for
(
const
QString
&
endpoint
:
preferCacheEndpoints
)
{
if
(
notConstReq
.
url
().
endsWith
(
endpoint
))
{
notConstReq
.
setAttribute
(
QNetworkRequest
::
CacheLoadControlAttribute
,
QNetworkRequest
::
PreferCache
);
QNetworkCacheMetaData
cacheMeta
{
m_accessManager
->
cache
.
metaData
(
notConstReq
.
url
())};
if
(
cacheMeta
.
isValid
())
{
// If the expiration date is valid, but longer than 24 hours, don't trust that things
// haven't changed and check first, otherwise just use the cached version to relieve
// server strain and reduce network traffic.
const
QDateTime
tomorrow
{
QDateTime
::
currentDateTime
().
addDays
(
1
)};
if
(
cacheMeta
.
expirationDate
().
isValid
()
&&
cacheMeta
.
expirationDate
()
<
tomorrow
)
{
notConstReq
.
setAttribute
(
QNetworkRequest
::
CacheLoadControlAttribute
,
QNetworkRequest
::
PreferCache
);
}
}
break
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment