Support If-Modified-Since in cross-site thread watcher requests.
This commit is contained in:
parent
7b2dee7279
commit
4b7b139311
@ -183,19 +183,15 @@ ThreadWatcher =
|
||||
else
|
||||
ThreadWatcher.status.textContent = "#{Math.round(ThreadWatcher.fetched / ThreadWatcher.requests.length * 100)}%"
|
||||
cb.apply @, args
|
||||
if siteID is Site.hostname
|
||||
if force
|
||||
delete $.lastModified.ThreadWatcher?[url]
|
||||
req = $.whenModified(
|
||||
url,
|
||||
'ThreadWatcher',
|
||||
onloadend,
|
||||
{timeout: $.MINUTE}
|
||||
)
|
||||
else
|
||||
req = CrossOrigin.ajax url,
|
||||
onloadend: onloadend
|
||||
timeout: $.MINUTE
|
||||
ajax = if siteID is Site.hostname then $.ajax else CrossOrigin.ajax
|
||||
if force
|
||||
delete $.lastModified.ThreadWatcher?[url]
|
||||
req = $.whenModified(
|
||||
url,
|
||||
'ThreadWatcher',
|
||||
onloadend,
|
||||
{timeout: $.MINUTE, ajax}
|
||||
)
|
||||
ThreadWatcher.requests.push req
|
||||
|
||||
clearRequests: ->
|
||||
|
||||
@ -82,7 +82,7 @@ $.ajax = do ->
|
||||
# This saves a lot of bandwidth and CPU time for both the users and the servers.
|
||||
$.lastModified = {}
|
||||
$.whenModified = (url, bucket, cb, options={}) ->
|
||||
{timeout} = options
|
||||
{timeout, ajax} = options
|
||||
params = []
|
||||
# XXX https://bugs.chromium.org/p/chromium/issues/detail?id=643659
|
||||
params.push "s=#{bucket}" if $.engine is 'blink'
|
||||
@ -92,7 +92,7 @@ $.whenModified = (url, bucket, cb, options={}) ->
|
||||
headers = {}
|
||||
if (t = $.lastModified[bucket]?[url0])?
|
||||
headers['If-Modified-Since'] = t
|
||||
r = $.ajax url, {
|
||||
r = (ajax or $.ajax) url, {
|
||||
onloadend: ->
|
||||
($.lastModified[bucket] or= {})[url0] = @getResponseHeader('Last-Modified')
|
||||
cb.call @
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user