func (r *Req) Request() (req *http.Request, err error) {
	if r.Err != nil {
		return nil, r.Err
	}

	body := &bytes.Buffer{}

	// set http body
	if r.bodyEncoder != nil {
		if err := r.bodyEncoder.Encode(body); err != nil {
			return nil, err
		}
	}

	// set query header
	if r.queryEncode != nil {
		if err := r.encodeQuery(); err != nil {
			return nil, err
		}
	}

	var f *encode.FormEncode

	// TODO
	// 可以考虑和 bodyEncoder合并,
	// 头疼的是f.FormDataContentType如何合并，每个encoder都实现这个方法???
	if r.formEncode != nil {
		f = encode.NewFormEncode(body)
		if err := encode.Encode(r.formEncode, f); err != nil {
			return nil, err
		}

		f.End()
	}

	req, err = r.selectRequest(body)
	if err != nil {
		return nil, err
	}
	// 放这个位置不会误删除SetForm的http header
	if r.headerEncode != nil {
		clearHeader(req.Header)
	}

	_ = r.GetContext()
	if r.c != nil {
		req = req.WithContext(r.c)
	}

	for _, c := range r.cookies {
		req.AddCookie(c)
	}

	if r.formEncode != nil {
		req.Header.Add("Content-Type", f.FormDataContentType())
	}

	// set http header
	if r.headerEncode != nil {
		err = r.encodeHeader(req)
		if err != nil {
			return nil, err
		}
	}

	r.addDefDebug()
	r.addContextType(req)
	return req, nil
}
// Request Get the http.Request object
Request Get the http.Request object
// Request Get the http . Request object
func (r *Req) Request() (req *http.Request, err error) {
	if r.Err != nil {
		return nil, r.Err
	}
	body := &bytes.Buffer{}
	if r.bodyEncoder != nil {
		if err := r.bodyEncoder.Encode(body); err != nil {
			return nil, err
		}
	}
	if r.queryEncode != nil {
		if err := r.encodeQuery(); err != nil {
			return nil, err
		}
	}
	var f *encode.FormEncode
	if r.formEncode != nil {
		f = encode.NewFormEncode(body)
		if err := encode.Encode(r.formEncode, f); err != nil {
			return nil, err
		}
		f.End()
	}
	req, err = r.selectRequest(body)
	if err != nil {
		return nil, err
	}
	if r.headerEncode != nil {
		clearHeader(req.Header)
	}
	_ = r.GetContext()
	if r.c != nil {
		req = req.WithContext(r.c)
	}
	for _, c := range r.cookies {
		req.AddCookie(c)
	}
	if r.formEncode != nil {
		req.Header.Add("Content-Type", f.FormDataContentType())
	}
	if r.headerEncode != nil {
		err = r.encodeHeader(req)
		if err != nil {
			return nil, err
		}
	}
	r.addDefDebug()
	r.addContextType(req)
	return req, nil
}
func ( r * Req ) Request ( ) ( req * http . Request , err error ) { if r . Err != nil { return nil , r . Err } body := & bytes . Buffer { } if r . bodyEncoder != nil { if err := r . bodyEncoder . Encode ( body ) ; err != nil { return nil , err } } if r . queryEncode != nil { if err := r . encodeQuery ( ) ; err != nil { return nil , err } } var f * encode . FormEncode if r . formEncode != nil { f = encode . NewFormEncode ( body ) if err := encode . Encode ( r . formEncode , f ) ; err != nil { return nil , err } f . End ( ) } req , err = r . selectRequest ( body ) if err != nil { return nil , err } if r . headerEncode != nil { clearHeader ( req . Header ) } _ = r . GetContext ( ) if r . c != nil { req = req . WithContext ( r . c ) } for _ , c := range r . cookies { req . AddCookie ( c ) } if r . formEncode != nil { req . Header . Add ( " " , f . FormDataContentType ( ) ) } if r . headerEncode != nil { err = r . encodeHeader ( req ) if err != nil { return nil , err } } r . addDefDebug ( ) r . addContextType ( req ) return req , nil }
Request Get the http.Request object
Request Get the http . Request object
// set http body // set query header // TODO // 可以考虑和 bodyEncoder合并, // 头疼的是f.FormDataContentType如何合并，每个encoder都实现这个方法??? // 放这个位置不会误删除SetForm的http header // set http header