mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-17 15:23:44 +08:00
Merge 1f72199473eb852e3df17a50a720dfe696b549cc into 0f09c3a9b4626d9fe9979cf4d0521d6ae32ab646
This commit is contained in:
commit
ad8468487c
@ -648,6 +648,9 @@ func (c *Context) initFormCache() {
|
||||
if c.formCache == nil {
|
||||
c.formCache = make(url.Values)
|
||||
req := c.Request
|
||||
if req == nil {
|
||||
return
|
||||
}
|
||||
if err := req.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {
|
||||
if !errors.Is(err, http.ErrNotMultipart) {
|
||||
debugPrint("error on parse multipart form array: %v", err)
|
||||
|
||||
@ -4055,3 +4055,13 @@ func BenchmarkGetMapFromFormData(b *testing.B) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextPostFormNoRequest(t *testing.T) {
|
||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||
|
||||
value, ok := c.GetPostForm("key")
|
||||
assert.False(t, ok)
|
||||
assert.Empty(t, value)
|
||||
assert.Empty(t, c.PostForm("key"))
|
||||
assert.Equal(t, "fallback", c.DefaultPostForm("key", "fallback"))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user