Working on a project, I just make an AJAX request to process some datas.
The server, once the job is done, returns a HTTP 205 RESET CONTENT
response
I use this status code to tell the requester to reset the document view
Here is the piece of code I use
$.ajax({
url: '/unread',
method: 'PUT',
data: {
notifications: elements
}
}).done(function(content, message, xhr) {
if (205 !== xhr.status) {
// Generic error message
return;
}
window.location.reload(true)
}).fail(function() {
// Generic error message
})
This works fine on Internet Explorer (8 and upwards) , Firefox (28.0) and Opera (12.16) . However Chrome (33.0) and Opera (20.0) instead of refreshing the page, downloads the response content of the page being reloaded dump when calling window.location.reload
Here's what I've tried
window.location.href = window.location.href
gives the same result history.go(0)
gives the same result window.location.reload
, nothing gets reloaded Here is the visual network of what's happening
Additionnal informations (and deeper investigations)
Why does Chrome and Opera behave like this on a 205
HTTP response?
The closest I could find was that it might be a bug, because in this file: https://chromium.googlesource.com/chromium/chromium/+/trunk/net/http/http_stream_parser.cc
the comment starting at line 837 does not match the code at line 850: ie the comment doesn't mention that a 205 must be of zero length, but the code treats 205 like 1xx, 204, and 304. That was actually the only blink code I could find that mentioned 205 (outside of defining constants).
It might also be worth trying the latest Opera version; if the problem also happens there, it points the finger more strongly at a bug in the Blink source code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.