Touki
Touki

Reputation: 7525

Chrome downloads the reloaded page on HTTP 205 response after an AJAX request

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 reloadeddump when calling window.location.reload

Here's what I've tried

Here is the visual network of what's happening

Chrome makes a download

Additionnal informations (and deeper investigations)

Why does Chrome and Opera behave like this on a 205 HTTP response?

Upvotes: 16

Views: 1487

Answers (1)

Darren Cook
Darren Cook

Reputation: 28978

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: i.e. 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.

Upvotes: 3

Related Questions