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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Bug]: c.Download Failure #2223

Open
3 tasks done
qmdx opened this issue Nov 16, 2022 · 12 comments
Open
3 tasks done

🐛 [Bug]: c.Download Failure #2223

qmdx opened this issue Nov 16, 2022 · 12 comments
Assignees

Comments

@qmdx
Copy link

qmdx commented Nov 16, 2022

Bug Description

c.Download Failure

How to Reproduce

Use the following two methods at the same time


app.Use("/", filesystem.New(filesystem.Config{
		Root:         http.FS(web.Dist),
		Browse:       true,
		Index:        "index.html",
		NotFoundFile: "404.html",
		PathPrefix:   "/dist",
		MaxAge:       3600,
	}))

app.Get("/download", func(c *fiber.Ctx) error {
      return c.Download("./test.txt", "test.txt")
})

Expected Behavior

/download Invalid request

Fiber Version

v2.39.0

Code Snippet (optional)

No response

Checklist:

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

qmdx commented Nov 16, 2022

This problem has been solved. Just adjust the order to

app.Get("/download", func(c *fiber.Ctx) error {
      return c.Download("./test.txt", "test.txt")
})

app.Use("/", filesystem.New(filesystem.Config{
		Root:         http.FS(web.Dist),
		Browse:       true,
		Index:        "index.html",
		NotFoundFile: "404.html",
		PathPrefix:   "/dist",
		MaxAge:       3600,
	}))

Now I'm not sure if it's a bug

@li-jin-gou
Copy link
Contributor

Let me see.

@li-jin-gou li-jin-gou self-assigned this Nov 19, 2022
@ReneWerner87
Copy link
Member

@li-jin-gou can we close the issue ?

@li-jin-gou
Copy link
Contributor

I'll try it today.💕

@G2G2G2G
Copy link
Contributor

G2G2G2G commented Mar 17, 2023

and the day went on and on.. it seemingly never ended and our heroes were trapped in the day forever.

@ReneWerner87
Copy link
Member

@li-jin-gou did you find time to check ?

@Rorke76753
Copy link
Contributor

Rorke76753 commented Mar 20, 2023

@ReneWerner87 it seems that fiber could not guarantee that the execution order of middleware and route in treeStack.(the execution order is relative to registration order e.g. this issue) I think the middleware might be executed before the routes ?( not sure :((( )

@ReneWerner87
Copy link
Member

ReneWerner87 commented Mar 20, 2023

fiber can guarantee the order
in version 2 we use the same logic as express and process the routes in the order in which they are registered

for more info please look here
https://docs.gofiber.io/guide/routing#paths

#1952 (comment)
#1090 (comment)
#1088 (comment)
#1469 (comment)

@Rorke76753
Copy link
Contributor

Rorke76753 commented Mar 20, 2023

fiber can guarantee the order in version 2 we use the same logic as express and process the routes in the order in which they are registered

for more info please look here https://docs.gofiber.io/guide/routing#paths

#1952 (comment) #1090 (comment) #1088 (comment) #1469 (comment)

thanks for reply! these help me a lot

@JacobYarn
Copy link

I'm tryed too

@nickajacks1
Copy link
Member

Since this issue seems to just be caused by the order of route execution, it seems like it can be closed.

@gaby
Copy link
Member

gaby commented Dec 28, 2023

@qmdx Can we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
8 participants