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

PostedFiles lost after trying to find nonexistent Param #67

Open
mat285 opened this issue May 15, 2019 · 0 comments
Open

PostedFiles lost after trying to find nonexistent Param #67

mat285 opened this issue May 15, 2019 · 0 comments
Labels
bug Something isn't working web applies to the web package

Comments

@mat285
Copy link
Collaborator

mat285 commented May 15, 2019

What happened:

Calling web.Ctx.PostedFiles or webutil.PostedFiles(web.Ctx.Request) returns no files if web.Ctx.Param("param") is called beforehand with a missing parameter.

What you expected to happen:

PostedFiles should return the files from the request even if web.Ctx.Param is called with a missing parameter

How to reproduce it (as minimally and precisely as possible):

app := web.New(web.OptBindAddr(":8080"), web.OptLog(logger.All()))

app.POST("/file", func(r *web.Ctx) web.Result {
	r.Param("non-existent")
	files, err := webutil.PostedFiles(r.Request)
	if err != nil {
		return web.Text.BadRequest(err)
	}
	fmt.Println("num files", len(files))
	return web.Text.OK()
})```


**Anything else we need to know?**:

This happens because the request gets consumed by the `r.Param` searching for all of the possible parameters

**Environment**:
- go-sdk version: master
- go version (e.g `go version`): go1.11.4 darwin/amd64
- OS (e.g: `cat /etc/os-release`): macOS 10.13.4
- Others:
@wcharczuk wcharczuk added bug Something isn't working web applies to the web package labels May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working web applies to the web package
Projects
None yet
Development

No branches or pull requests

2 participants