3

when I try to Respond with on HTTP 204 Status, my Chrome browser is starting an Download that fails.

Request: Request URL: https://dummy.page/dummyRequest Request Method: GET Status Code: 204 Remote Address: [dummy]:443 Referrer Policy: no-referrer-when-downgrade

Response: date: Fri, 08 Mar 2019 08:24:05 GMT server: status: 204

When I use Dev-Tool to inspect the response, chrome says "faild to load response data" and in firefox I can see one empty line.

My server returns a Response via Java:

return Response.noContent().build();

I also tried to return NULL at this point but that did not change anything.

The whole thing is working fine in Firefox but when I try in Chrome it starts an Download of "dummyRequest" (from the URL) which fails.

So what I want to know: why is Chrome starting a download and what could I do against?

Thanks for helping ;)

Jfgnome
  • 31
  • 3
  • I would also really like to know the answer to this question. I really don't understand why Chrome would try to download a page marked "No Content." The download fails, because.... wait for it.. there's no content. Not sure if this is some issue with how I'm sending headers or if it's a bug in Chrome. – Layne Bernardo Nov 11 '19 at 18:59

1 Answers1

0

I came across the same issue with 204 responses. What worked for me was checking the Content-Type response header on the server-side before sending the response.

My 204 responses were sending a default Content-Type of application/octet-stream (from the link: "An unknown file type should use this type. Browsers pay a particular care when manipulating these files"). When switching the Content-Type to something different (I chose text/html), the trigger for downloads stopped.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jen
  • 47
  • 3