Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
If there any bug on multipart form data file receiving? Browser on windows 10 cannot receive response correctly when use auth middleware to reject the request before execute any operational function.
Description
Env
Windows 10
Edge browser (Chromium)
Process to error:
Big size file, over 2 MB
Uploading file with multipart form with any browser supported js function such as xhr, fetch or others
If server code do not process the received form data in handler, but return response directly such as when auth fails.
You will get connection_reset error on browser.
Process to success:
Just change the place of return statement on server code to be after any codes that have processed the received data.
By the way, no problem if use curl to send request directly or use postman to help construct the request.
// c.ShouldBind(&obj) -- before return, browser received 401 correctly
c.JSON(401, gin.H{"test": "test"})
return
// c.ShouldBind(&obj) -- after return, which means server does not do anything about the post data, browser will get connection_reset error
Question
If there any bug on multipart form data file receiving? Browser on windows 10 cannot receive response correctly when use auth middleware to reject the request before execute any operational function.
Description
Env Windows 10 Edge browser (Chromium)
Process to error:
Process to success: Just change the place of return statement on server code to be after any codes that have processed the received data.
By the way, no problem if use curl to send request directly or use postman to help construct the request.
How to reproduce
import ( "github.com/gin-gonic/gin" "github.com/gin-contrib/cors" "mime/multipart" "net/http" "strings" )
type ProfileForm struct { Files []*multipart.FileHeader
form:"files" binding:"required"
Json stringform:"json" binding:"required"
}func main() { router := gin.Default() router.Use(cors.New(cors.Config{ AllowMethods: []string{"PUT", "PATCH", "POST", "OPTIONS"}, AllowHeaders: []string{"Origin"}, ExposeHeaders: []string{"Content-Length"}, AllowCredentials: true, AllowOriginFunc: func(origin string) bool { return true }, MaxAge: 12 * time.Hour, }))
}
<!DOCTYPE html>