err error) {
                  
                  
                    if r.Body == nil {
                  
                  
                      err = errors.New("missing form body")
                  
                  
                      return
                  
                  
                    }
                  
                  
                    ct := r.Header.Get("Content-Type")
                  
                  
                    // RFC 7231, section 3.1.1.5 - empty type
                  
                  
                    //   MAY be treated as application/octet-stream
                  
                  
                    if ct == "" {
                  
                  
                      ct = "application/octet-stream"
                  
                  
                    }
                  
                  
                    ct, _, err = mime.ParseMediaType(ct)
                  
                  
                    switch {
                  
                  
                    case ct == "application/x-www-form-urlencoded":
                  
                  
                      var reader io.Reader = r.Body
                  
                  
                      maxFormSize := int64(1<<63 - 1)
                  
                  
                      if _, ok := r.Body.(*maxBytesReader); !ok {
                  
                  
                        maxFormSize = int64(10 << 20) // 10 MB is a lot of text.
                  
                  
                        reader = io.LimitReader(r.Body, maxFormSize+1)
                  
                  
                      }
                  
                  
                      b, e := ioutil.ReadAll(reader)
                  
                  
                      if e != nil {
                  
                  
                        if err == nil {
                  
                  
                          err = e
                  
                  
                        }
                  
                  
                        break
                  
                  
                      }
                  
                  
                      if int64(len(b)) > maxFormSize {
                  
                  
                        err = errors.New("http: POST too large")
                  
                  
                        return
                  
                  
                      }
                  
                  
                      vs, e = url.ParseQuery(string(b))
                  
                  
                      if err == nil {
                  
                  
                        err = e
                  
                  
                      }
                  
                  
                    case ct == "multipart/form-data":
                  
                  
                      // handled by ParseMultipartForm (which is calling us, or should be)
                  
                  
                      // TODO(bradfitz): there are too many possible
                  
                  
                      // orders to call too many functions here.
                  
                  
                      // Clean this up and write more tests.
                  
                  
                      // request_test.go contains the start of this,
                  
                  
                      // in TestParseMultipartFormOrder and others.
                  
                  
                    }
                  
                  
                    return
                  
                  
                  }
                  
                  
                
не очень понял, зачем эта копипаста из стдлибы
Кидай уж на pastebin..
Обсуждают сегодня