fix object storage nil pointer deref error
diff --git a/openstack/objectstorage/v1/accounts/requests.go b/openstack/objectstorage/v1/accounts/requests.go
index a645115..66c46a9 100644
--- a/openstack/objectstorage/v1/accounts/requests.go
+++ b/openstack/objectstorage/v1/accounts/requests.go
@@ -43,7 +43,9 @@
MoreHeaders: h,
OkCodes: []int{204},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
@@ -97,7 +99,9 @@
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
diff --git a/openstack/objectstorage/v1/containers/requests.go b/openstack/objectstorage/v1/containers/requests.go
index bbf8cdb..50ff9f4 100644
--- a/openstack/objectstorage/v1/containers/requests.go
+++ b/openstack/objectstorage/v1/containers/requests.go
@@ -114,7 +114,9 @@
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
@@ -180,7 +182,9 @@
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
@@ -193,7 +197,9 @@
resp, err := c.Request("HEAD", getURL(c, containerName), gophercloud.RequestOpts{
OkCodes: []int{200, 204},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
diff --git a/openstack/objectstorage/v1/objects/requests.go b/openstack/objectstorage/v1/objects/requests.go
index 62c006a..b9a0e7e 100644
--- a/openstack/objectstorage/v1/objects/requests.go
+++ b/openstack/objectstorage/v1/objects/requests.go
@@ -134,10 +134,11 @@
MoreHeaders: h,
OkCodes: []int{200, 304},
})
-
- res.Body = resp.Body
+ if resp != nil {
+ res.Header = resp.Header
+ res.Body = resp.Body
+ }
res.Err = err
- res.Header = resp.Header
return res
}
@@ -214,7 +215,9 @@
}
resp, err := c.Request("PUT", url, ropts)
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
@@ -270,7 +273,9 @@
MoreHeaders: h,
OkCodes: []int{201},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
@@ -310,7 +315,9 @@
}
resp, err := c.Delete(url, nil)
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
@@ -354,7 +361,9 @@
resp, err := c.Request("HEAD", url, gophercloud.RequestOpts{
OkCodes: []int{200, 204},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
@@ -410,7 +419,9 @@
resp, err := c.Request("POST", url, gophercloud.RequestOpts{
MoreHeaders: h,
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
diff --git a/rackspace/objectstorage/v1/bulk/requests.go b/rackspace/objectstorage/v1/bulk/requests.go
index 898b73b..0aeec15 100644
--- a/rackspace/objectstorage/v1/bulk/requests.go
+++ b/rackspace/objectstorage/v1/bulk/requests.go
@@ -43,7 +43,9 @@
JSONBody: reqBody,
JSONResponse: &res.Body,
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
diff --git a/rackspace/objectstorage/v1/cdncontainers/requests.go b/rackspace/objectstorage/v1/cdncontainers/requests.go
index 8e4abbe..6acebb0 100644
--- a/rackspace/objectstorage/v1/cdncontainers/requests.go
+++ b/rackspace/objectstorage/v1/cdncontainers/requests.go
@@ -53,7 +53,9 @@
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
@@ -66,7 +68,9 @@
resp, err := c.Request("HEAD", getURL(c, containerName), gophercloud.RequestOpts{
OkCodes: []int{200, 204},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}
@@ -149,7 +153,9 @@
MoreHeaders: h,
OkCodes: []int{202, 204},
})
- res.Header = resp.Header
+ if resp != nil {
+ res.Header = resp.Header
+ }
res.Err = err
return res
}