download.go 527 B

12345678910111213141516171819202122232425262728
  1. package imagedata
  2. import (
  3. "context"
  4. "net/http"
  5. )
  6. var (
  7. // For tests. This needs to move to fetcher once we will have a way to isolate
  8. // the fetcher in tests.
  9. redirectAllRequestsTo string
  10. )
  11. type DownloadOptions struct {
  12. Header http.Header
  13. CookieJar http.CookieJar
  14. MaxSrcFileSize int
  15. DownloadFinished context.CancelFunc
  16. }
  17. // TODO: get rid of this global variable
  18. func RedirectAllRequestsTo(u string) {
  19. redirectAllRequestsTo = u
  20. }
  21. func StopRedirectingRequests() {
  22. redirectAllRequestsTo = ""
  23. }