Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 [Question]: How can I disable 304 responses with c.SendFile(), c.Download(), or Filesystem middleware? #2965

Closed
3 tasks done
xEricL opened this issue Apr 13, 2024 · 4 comments

Comments

@xEricL
Copy link

xEricL commented Apr 13, 2024

Question Description

I am using c.Download() to send files within a handler. Sometimes it responses with 304. However, I want it to always respond with 200 (assuming the file is found).

How can I do that? Is it as simple as:

return c.Status(fiber.StatusOK).Download(filepath, filename)

I believe the 304 response mechanism was implemented in response to this bug report #516

However, it appears that the solution assumes the app is sending files to a browser. In my case, requests made to my app do not come from a browser.

Code Snippet (optional)

No response

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my questions prior to opening this one.
  • I understand that improperly formatted questions may be closed without explanation.
@gaby
Copy link
Member

gaby commented Apr 13, 2024

@xEricL HTTP 304 Not Modified is a status code used to indicate that the requested resource has not changed since the last time it was requested, and therefore, the client can continue to use the cached version of the resource instead of re-downloading it. This status code is typically used in conjunction with HTTP headers like If-Modified-Since or If-None - Match. This ia why you see HTTP 200 for the first request, but 304 after.

@xEricL
Copy link
Author

xEricL commented Apr 13, 2024

@gaby yeah I understand the status code. But in my case, requests are made from a java app, not from a browser. The java app expects a 200, but instead the client is receiving a 304, which would cause the client-side code to fail if it errors out on non-200 responses.

I understand that this can be disabled if I'm using App.Static(). However, there doesn't seem to be a way to disable it for c.SendFile() responses in a regular handler.

@xEricL
Copy link
Author

xEricL commented Apr 14, 2024

Just realized, this is pretty much a duplicate of #2945

@xEricL xEricL closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2024
@gaby
Copy link
Member

gaby commented Apr 14, 2024

@xEricL Yeah, you are right it's the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants