http.go
func (req *Request) MultipartForm() (*multipart.Form, error) {
	if req.multipartForm != nil {
		return req.multipartForm, nil
	}

	req.multipartFormBoundary = string(req.Header.MultipartFormBoundary())
	if len(req.multipartFormBoundary) == 0 {
		return nil, ErrNoMultipartForm
	}

	ce := req.Header.peek(strContentEncoding)
	body := req.bodyBytes()
	if bytes.Equal(ce, strGzip) {
		// Do not care about memory usage here.
		var err error
		if body, err = AppendGunzipBytes(nil, body); err != nil {
			return nil, fmt.Errorf("cannot gunzip request body: %s", err)
		}
	} else if len(ce) > 0 {
		return nil, fmt.Errorf("unsupported Content-Encoding: %q", ce)
	}

	f, err := readMultipartForm(bytes.NewReader(body), req.multipartFormBoundary, len(body), len(body))
	if err != nil {
		return nil, err
	}
	req.multipartForm = f
	return f, nil
}
func (req *Request) MultipartForm() (*multipart.Form, error) {
	if req.multipartForm != nil {
		return req.multipartForm, nil
	}

	req.multipartFormBoundary = string(req.Header.MultipartFormBoundary())
	if len(req.multipartFormBoundary) == 0 {
		return nil, ErrNoMultipartForm
	}

	ce := req.Header.peek(strContentEncoding)
	body := req.bodyBytes()
	if bytes.Equal(ce, strGzip) {
		// Do not care about memory usage here.
		var err error
		if body, err = AppendGunzipBytes(nil, body); err != nil {
			return nil, fmt.Errorf("cannot gunzip request body: %s", err)
		}
	} else if len(ce) > 0 {
		return nil, fmt.Errorf("unsupported Content-Encoding: %q", ce)
	}

	f, err := readMultipartForm(bytes.NewReader(body), req.multipartFormBoundary, len(body), len(body))
	if err != nil {
		return nil, err
	}
	req.multipartForm = f
	return f, nil
}
func ( req * Request ) MultipartForm ( ) ( * multipart . Form , error ) { if req . multipartForm != nil { return req . multipartForm , nil } req . multipartFormBoundary = string ( req . Header . MultipartFormBoundary ( ) ) if len ( req . multipartFormBoundary ) == 0 { return nil , ErrNoMultipartForm } ce := req . Header . peek ( strContentEncoding ) body := req . bodyBytes ( ) if bytes . Equal ( ce , strGzip ) { // Do not care about memory usage here. var err error if body , err = AppendGunzipBytes ( nil , body ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } } else if len ( ce ) > 0 { return nil , fmt . Errorf ( " " , ce ) } f , err := readMultipartForm ( bytes . NewReader ( body ) , req . multipartFormBoundary , len ( body ) , len ( body ) ) if err != nil { return nil , err } req . multipartForm = f return f , nil }
// MultipartForm returns requests's multipart form.
//
// Returns ErrNoMultipartForm if request's Content-Type
// isn't 'multipart/form-data'.
//
// RemoveMultipartFormFiles must be called after returned multipart form
// is processed.
MultipartForm returns requests s multipart form . Returns ErrNoMultipartForm if request s Content - Type isn t multipart / form - data . RemoveMultipartFormFiles must be called after returned multipart form is processed .