summaryrefslogtreecommitdiff
path: root/rhimport/fetcher.go
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport/fetcher.go')
-rw-r--r--rhimport/fetcher.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go
index 324ee5d..b78ea02 100644
--- a/rhimport/fetcher.go
+++ b/rhimport/fetcher.go
@@ -159,6 +159,13 @@ func fetchFileCurl(ctx *Context, res *Result, uri *url.URL) (err error) {
easy.Setopt(curl.OPT_PROGRESSDATA, cbdata)
err = easy.Perform()
+ statusCode := 0
+ if curlResponseCode, err := easy.Getinfo(curl.INFO_RESPONSE_CODE); err == nil {
+ if code, ok := curlResponseCode.(int); ok {
+ statusCode = code
+ }
+ }
+
var convOut string
var convErr error
if cbdata.conv != nil {
@@ -176,6 +183,11 @@ func fetchFileCurl(ctx *Context, res *Result, uri *url.URL) (err error) {
rhl.Printf("download of '%s' got canceled", ctx.SourceUri)
return nil
}
+ if statusCode > 0 && statusCode != http.StatusOK {
+ res.ResponseCode = statusCode
+ res.ErrorString = fmt.Sprintf("non-OK response code (%d) while fetching the resource", statusCode)
+ return nil
+ }
if cbdata.writeError != nil {
err = cbdata.writeError
}