Timeout added in downloadhelper.mdl

Merged Kunal Taitkar requested to merge kunalt_downloadManager into devbranch
Compare and
1 file
+ 13
1
Preferences
File browser
Compare changes
@@ -52,6 +52,7 @@ type DownloadParameter struct {
jwtToken string
isCacheBurst bool
fileHashedValue string
requestTimeOut int64
DownloadError error
}
@@ -82,6 +83,11 @@ func (dh *DownloadHelper) AddParamsCacheBurst(isCacheBurst bool) *DownloadHelper
return dh
}
func (dh *DownloadHelper) AddRequestTimeout(requestTimeOutValue int64) *DownloadHelper {
dh.DownloadParam.requestTimeOut = requestTimeOutValue
return dh
}
// Run all Steps one by one
func (dh *DownloadHelper) Run() *DownloadHelper {
_, dh.DownloadParam.DownloadError = DownloadFile(dh)
@@ -182,8 +188,14 @@ func downloadFileFromCloud(params *DownloadHelper) error {
defer out.Close()
//TODO: Code might be refactor (in case provision is given in httpmdl)
if params.DownloadParam.requestTimeOut <= 0 {
params.DownloadParam.requestTimeOut = 0
}
// Fetching data from httpClient
client := &http.Client{}
client := &http.Client{
Timeout: time.Duration(params.DownloadParam.requestTimeOut) * time.Second,
}
// Call to fetch content
req, err := http.NewRequest("GET", params.sourceURL, nil)