Merge 9b5c2e4046ee5c111c4044af0702aa5649200823 into dcaa4296d111981ffb31ac3eba90bb63e1eb5ab9

This commit is contained in:
Sai Asish Y 2026-08-24 19:17:50 -07:00 committed by GitHub
commit 45dacf97e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -649,6 +649,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)

View File

@ -3955,3 +3955,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"))
}