Commit 1735ad7f authored by Ajit Jagtap's avatar Ajit Jagtap
Browse files

Merge branch 'kunalt_downloadManager' into 'devbranch'

Timeout added in downloadhelper.mdl

See merge request !111
parents 75d44034 145d1cee
Branches
Tags
2 merge requests!11331 Aug MEP Merge Dev to Stg,!111Timeout added in downloadhelper.mdl
Showing with 13 additions and 1 deletion
......@@ -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)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment