mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 11:28:24 +00:00 
			
		
		
		
	Backport #33840 by wxiaoguang Fix #33839 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -8,6 +8,7 @@ import ( | ||||
| 	"bytes" | ||||
| 	"context" | ||||
| 	"crypto/tls" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"net" | ||||
| @@ -101,6 +102,9 @@ func (r *Request) Param(key, value string) *Request { | ||||
|  | ||||
| // Body adds request raw body. It supports string, []byte and io.Reader as body. | ||||
| func (r *Request) Body(data any) *Request { | ||||
| 	if r == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	switch t := data.(type) { | ||||
| 	case nil: // do nothing | ||||
| 	case string: | ||||
| @@ -193,6 +197,9 @@ func (r *Request) getResponse() (*http.Response, error) { | ||||
| // Response executes request client gets response manually. | ||||
| // Caller MUST close the response body if no error occurs | ||||
| func (r *Request) Response() (*http.Response, error) { | ||||
| 	if r == nil { | ||||
| 		return nil, errors.New("invalid request") | ||||
| 	} | ||||
| 	return r.getResponse() | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user