Added setting content-type similar to net/http in Post

This commit is contained in:
Tracker-Friendly 2024-10-28 09:56:45 +00:00
parent 648929a894
commit b9f75dd54f
1 changed files with 2 additions and 1 deletions

View File

@ -656,11 +656,12 @@ func Get(url string) (response *Response, err error) {
return return
} }
func Post(url string, body io.Reader) (response *Response, err error) { func Post(url string, contentType string, body io.Reader) (response *Response, err error) {
request, err := NewRequest("POST", url, body) request, err := NewRequest("POST", url, body)
if err != nil { if err != nil {
return return
} }
request.Header.Add("Content-Type", contentType)
response, err = Fetch.Do(request) response, err = Fetch.Do(request)
return return
} }