MCPcopy
hub / github.com/gogs/gogs / ToFile

Method ToFile

internal/httplib/httplib.go:405–422  ·  view source on GitHub ↗

ToFile saves the body data in response to one file. it calls Response inner.

(filename string)

Source from the content-addressed store, hash-verified

403// ToFile saves the body data in response to one file.
404// it calls Response inner.
405func (r *Request) ToFile(filename string) error {
406 f, err := os.Create(filename)
407 if err != nil {
408 return err
409 }
410 defer f.Close()
411
412 resp, err := r.getResponse()
413 if err != nil {
414 return err
415 }
416 if resp.Body == nil {
417 return nil
418 }
419 defer resp.Body.Close()
420 _, err = io.Copy(f, resp.Body)
421 return err
422}
423
424// Response executes request client gets response manually.
425func (r *Request) Response() (*http.Response, error) {

Callers

nothing calls this directly

Calls 2

getResponseMethod · 0.95
CreateMethod · 0.45

Tested by

no test coverage detected