ソースを参照

PostForm() handles multipart post

Manu Mtz-Almeida 10 年 前
コミット
500d745123
1 ファイル変更6 行追加3 行削除
  1. 6 3
      context.go

+ 6 - 3
context.go

@@ -30,8 +30,6 @@ const (
 
 const AbortIndex = math.MaxInt8 / 2
 
-var _ context.Context = &Context{}
-
 // Param is a single URL parameter, consisting of a key and a value.
 type Param struct {
 	Key   string
@@ -76,6 +74,8 @@ type Context struct {
 	Accepted []string
 }
 
+var _ context.Context = &Context{}
+
 /************************************/
 /********** CONTEXT CREATION ********/
 /************************************/
@@ -231,10 +231,13 @@ func (c *Context) query(key string) (string, bool) {
 
 func (c *Context) postForm(key string) (string, bool) {
 	req := c.Request
-	req.ParseForm()
+	req.ParseMultipartForm(32 << 20) // 32 MB
 	if values, ok := req.PostForm[key]; ok && len(values) > 0 {
 		return values[0], true
 	}
+	if values, ok := req.MultipartForm.Value[key]; ok && len(values) > 0 {
+		return values[0], true
+	}
 	return "", false
 }