Cleanup s3 client, iodize it as well
This commit is contained in:
@@ -23,13 +23,17 @@ import (
|
||||
|
||||
// Client - client interface
|
||||
type Client interface {
|
||||
// Bucket operations
|
||||
PutBucket(bucket string) error
|
||||
StatBucket(bucket string) error
|
||||
ListBuckets() ([]*Bucket, error)
|
||||
ListObjects(bucket, keyPrefix string) (items []*Item, err error)
|
||||
|
||||
// Object operations
|
||||
Get(bucket, object string) (body io.ReadCloser, size int64, md5 string, err error)
|
||||
GetPartial(bucket, key string, offset, length int64) (body io.ReadCloser, size int64, md5 string, err error)
|
||||
Put(bucket, object, md5 string, size int64, body io.Reader) error
|
||||
Stat(bucket, object string) (size int64, date time.Time, err error)
|
||||
PutBucket(bucket string) error
|
||||
ListBuckets() ([]*Bucket, error)
|
||||
ListObjects(bucket, keyPrefix string) (items []*Item, err error)
|
||||
StatObject(bucket, object string) (size int64, date time.Time, err error)
|
||||
}
|
||||
|
||||
// Bucket - carries s3 bucket reply header
|
||||
|
||||
+33
-138
@@ -39,19 +39,14 @@ limitations under the License.
|
||||
package s3
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"encoding/xml"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/minio-io/iodine"
|
||||
"github.com/minio-io/mc/pkg/client"
|
||||
)
|
||||
|
||||
@@ -66,8 +61,8 @@ func (a bySize) Less(i, j int) bool { return a[i].Size < a[j].Size }
|
||||
|
||||
// ListBuckets - Get list of buckets
|
||||
func (c *s3Client) ListBuckets() ([]*client.Bucket, error) {
|
||||
url := fmt.Sprintf("%s://%s/", c.Scheme, c.Host)
|
||||
req := newReq(url)
|
||||
u := fmt.Sprintf("%s://%s/", c.Scheme, c.Host)
|
||||
req := newReq(u)
|
||||
c.signRequest(req, c.Host)
|
||||
|
||||
res, err := c.Transport.RoundTrip(req)
|
||||
@@ -80,21 +75,21 @@ func (c *s3Client) ListBuckets() ([]*client.Bucket, error) {
|
||||
return nil, NewError(res)
|
||||
}
|
||||
|
||||
return parseListAllMyBuckets(res.Body)
|
||||
return listAllMyBuckets(res.Body)
|
||||
}
|
||||
|
||||
// PutBucket - create new bucket
|
||||
func (c *s3Client) PutBucket(bucket string) error {
|
||||
var url string
|
||||
if IsValidBucketName(bucket) && !strings.Contains(bucket, ".") {
|
||||
url = fmt.Sprintf("%s://%s/%s", c.Scheme, c.Host, bucket)
|
||||
if !IsValidBucketName(bucket) || strings.Contains(bucket, ".") {
|
||||
return errors.New("invalid bucket")
|
||||
}
|
||||
req := newReq(url)
|
||||
u := fmt.Sprintf("%s://%s/%s", c.Scheme, c.Host, bucket)
|
||||
req := newReq(u)
|
||||
req.Method = "PUT"
|
||||
c.signRequest(req, c.Host)
|
||||
res, err := c.Transport.RoundTrip(req)
|
||||
if err != nil {
|
||||
return err
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
@@ -105,146 +100,46 @@ func (c *s3Client) PutBucket(bucket string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Try the enumerate 5 times, since Amazon likes to close
|
||||
// https connections a lot, and Go sucks at dealing with it:
|
||||
// https://code.google.com/p/go/issues/detail?id=3514
|
||||
func (c *s3Client) retry(urlReq string) (listBucketResults, error) {
|
||||
const maxTries = 5
|
||||
bres := listBucketResults{}
|
||||
for try := 1; try <= maxTries; try++ {
|
||||
time.Sleep(time.Duration(try-1) * 100 * time.Millisecond)
|
||||
req := newReq(urlReq)
|
||||
c.signRequest(req, c.Host)
|
||||
res, err := c.Transport.RoundTrip(req)
|
||||
if err != nil {
|
||||
if try < maxTries {
|
||||
continue
|
||||
}
|
||||
return listBucketResults{}, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return listBucketResults{}, NewError(res)
|
||||
}
|
||||
|
||||
var logbuf bytes.Buffer
|
||||
err = xml.NewDecoder(io.TeeReader(res.Body, &logbuf)).Decode(&bres)
|
||||
if err != nil {
|
||||
fmt.Printf("Error parsing s3 XML response: %v for %q\n", err, logbuf.Bytes())
|
||||
if try < maxTries-1 {
|
||||
fmt.Printf("Reconnecting...\n")
|
||||
continue
|
||||
}
|
||||
return listBucketResults{}, err
|
||||
}
|
||||
break
|
||||
func (c *s3Client) StatBucket(bucket string) error {
|
||||
if bucket == "" {
|
||||
return iodine.New(errors.New("invalid argument"), nil)
|
||||
}
|
||||
return bres, nil
|
||||
}
|
||||
|
||||
func (c *s3Client) getItems(s, m string, contents []*client.Item) (items []*client.Item, marker string, err error) {
|
||||
for _, it := range contents {
|
||||
if it.Key == m && it.Key != s {
|
||||
// Skip first dup on pages 2 and higher.
|
||||
continue
|
||||
}
|
||||
if it.Key < s {
|
||||
msg := fmt.Sprintf("Unexpected response from Amazon: item key %q but wanted greater than %q", it.Key, s)
|
||||
return nil, m, errors.New(msg)
|
||||
}
|
||||
items = append(items, it)
|
||||
marker = it.Key
|
||||
if !IsValidBucketName(bucket) || strings.Contains(bucket, ".") {
|
||||
return errors.New("invalid bucket")
|
||||
}
|
||||
return items, marker, nil
|
||||
}
|
||||
u := fmt.Sprintf("%s://%s/%s", c.Scheme, c.Host, bucket)
|
||||
req := newReq(u)
|
||||
req.Method = "HEAD"
|
||||
c.signRequest(req, c.Host)
|
||||
res, err := c.Transport.RoundTrip(req)
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
func (c *s3Client) getPrefixes(commonPrefixes []*client.Prefix) (prefixes []*client.Prefix, err error) {
|
||||
for _, pre := range commonPrefixes {
|
||||
if pre.Prefix != "" {
|
||||
prefixes = append(prefixes, pre)
|
||||
}
|
||||
switch res.StatusCode {
|
||||
case http.StatusNotFound:
|
||||
return iodine.New(os.ErrNotExist, nil)
|
||||
case http.StatusOK:
|
||||
return nil
|
||||
default:
|
||||
return iodine.New(NewError(res), nil)
|
||||
}
|
||||
return prefixes, nil
|
||||
}
|
||||
|
||||
func (c *s3Client) ListObjects(bucket, objectPrefix string) (items []*client.Item, err error) {
|
||||
size, date, err := c.Stat(bucket, objectPrefix)
|
||||
size, date, err := c.StatObject(bucket, objectPrefix)
|
||||
switch err {
|
||||
case nil: // List a single object. Exact key
|
||||
items = append(items, &client.Item{Key: objectPrefix, LastModified: date, Size: size})
|
||||
return items, nil
|
||||
case os.ErrNotExist:
|
||||
default:
|
||||
// List all objects matching the key prefix
|
||||
items, _, err = c.queryObjects(bucket, "", objectPrefix, "", globalMaxKeys)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
// even if items are equal to '0' is valid case
|
||||
return items, nil
|
||||
default: // Error
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// queryObjects returns 0 to maxKeys (inclusive) items from the
|
||||
// provided bucket. Keys before startAt will be skipped. (This is the S3
|
||||
// 'marker' value). If the length of the returned items is equal to
|
||||
// maxKeys, there is no indication whether or not the returned list is truncated.
|
||||
func (c *s3Client) queryObjects(bucket string, startAt, prefix, delimiter string, maxKeys int) (items []*client.Item, prefixes []*client.Prefix, err error) {
|
||||
var urlReq string
|
||||
var buffer bytes.Buffer
|
||||
|
||||
if maxKeys <= 0 {
|
||||
return nil, nil, errors.New("negative maxKeys are invalid")
|
||||
}
|
||||
|
||||
marker := startAt
|
||||
for len(items) < maxKeys {
|
||||
fetchN := maxKeys - len(items)
|
||||
if fetchN > globalMaxKeys {
|
||||
fetchN = globalMaxKeys
|
||||
}
|
||||
var bres listBucketResults
|
||||
buffer.WriteString(fmt.Sprintf("%s?max-keys=%d", c.bucketURL(bucket), fetchN))
|
||||
switch true {
|
||||
case marker != "":
|
||||
buffer.WriteString(fmt.Sprintf("&marker=%s", url.QueryEscape(marker)))
|
||||
fallthrough
|
||||
case prefix != "":
|
||||
buffer.WriteString(fmt.Sprintf("&prefix=%s", url.QueryEscape(prefix)))
|
||||
fallthrough
|
||||
case delimiter != "":
|
||||
buffer.WriteString(fmt.Sprintf("&delimiter=%s", url.QueryEscape(delimiter)))
|
||||
}
|
||||
|
||||
urlReq = buffer.String()
|
||||
bres, err = c.retry(urlReq)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if bres.MaxKeys != fetchN || bres.Name != bucket || bres.Marker != marker {
|
||||
msg := fmt.Sprintf("Unexpected parse from server: %#v", bres)
|
||||
err = errors.New(msg)
|
||||
return nil, nil, err
|
||||
}
|
||||
items, marker, err = c.getItems(startAt, marker, bres.Contents)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
prefixes, err = c.getPrefixes(bres.CommonPrefixes)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if !bres.IsTruncated {
|
||||
break
|
||||
}
|
||||
|
||||
if len(items) == 0 {
|
||||
return nil, nil, errors.New("No items replied")
|
||||
}
|
||||
}
|
||||
sort.Sort(bySize(items))
|
||||
return items, prefixes, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
package s3
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/minio-io/iodine"
|
||||
"github.com/minio-io/mc/pkg/client"
|
||||
)
|
||||
|
||||
// Try the enumerate 5 times, since Amazon likes to close
|
||||
// https connections a lot, and Go sucks at dealing with it:
|
||||
// https://code.google.com/p/go/issues/detail?id=3514
|
||||
func (c *s3Client) retryRequest(urlReq string) (listBucketResults, error) {
|
||||
const maxTries = 5
|
||||
bres := listBucketResults{}
|
||||
for try := 1; try <= maxTries; try++ {
|
||||
time.Sleep(time.Duration(try-1) * 100 * time.Millisecond)
|
||||
req := newReq(urlReq)
|
||||
c.signRequest(req, c.Host)
|
||||
res, err := c.Transport.RoundTrip(req)
|
||||
if err != nil {
|
||||
if try < maxTries {
|
||||
continue
|
||||
}
|
||||
return listBucketResults{}, iodine.New(err, nil)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return listBucketResults{}, iodine.New(NewError(res), nil)
|
||||
}
|
||||
|
||||
var logbuf bytes.Buffer
|
||||
err = xml.NewDecoder(io.TeeReader(res.Body, &logbuf)).Decode(&bres)
|
||||
if err != nil {
|
||||
fmt.Printf("Error parsing s3 XML response: %v for %q\n", err, logbuf.Bytes())
|
||||
if try < maxTries-1 {
|
||||
fmt.Printf("Reconnecting...\n")
|
||||
continue
|
||||
}
|
||||
return listBucketResults{}, iodine.New(err, nil)
|
||||
}
|
||||
break
|
||||
}
|
||||
return bres, nil
|
||||
}
|
||||
|
||||
// get items out of content and provide marker for future request
|
||||
func (c *s3Client) getItems(s, m string, contents []*client.Item) (items []*client.Item, marker string, err error) {
|
||||
for _, it := range contents {
|
||||
if it.Key == m && it.Key != s {
|
||||
// Skip first dup on pages 2 and higher.
|
||||
continue
|
||||
}
|
||||
if it.Key < s {
|
||||
msg := fmt.Sprintf("Unexpected response from Amazon: item key %q but wanted greater than %q", it.Key, s)
|
||||
return nil, m, iodine.New(errors.New(msg), nil)
|
||||
}
|
||||
items = append(items, it)
|
||||
marker = it.Key
|
||||
}
|
||||
return items, marker, nil
|
||||
}
|
||||
|
||||
// queryObjects returns 0 to maxKeys (inclusive) items from the
|
||||
// provided bucket. Keys before startAt will be skipped. (This is the S3
|
||||
// 'marker' value). If the length of the returned items is equal to
|
||||
// maxKeys, there is no indication whether or not the returned list is truncated.
|
||||
func (c *s3Client) queryObjects(bucket string, startAt, prefix, delimiter string, maxKeys int) (items []*client.Item, prefixes []*client.Prefix, err error) {
|
||||
var urlReq string
|
||||
var buffer bytes.Buffer
|
||||
|
||||
if maxKeys <= 0 {
|
||||
return nil, nil, iodine.New(errors.New("negative maxKeys are invalid"), nil)
|
||||
}
|
||||
|
||||
marker := startAt
|
||||
for len(items) < maxKeys {
|
||||
fetchN := maxKeys - len(items)
|
||||
if fetchN > globalMaxKeys {
|
||||
fetchN = globalMaxKeys
|
||||
}
|
||||
var bres listBucketResults
|
||||
buffer.WriteString(fmt.Sprintf("%s?max-keys=%d", c.bucketURL(bucket), fetchN))
|
||||
switch true {
|
||||
case marker != "":
|
||||
buffer.WriteString(fmt.Sprintf("&marker=%s", url.QueryEscape(marker)))
|
||||
fallthrough
|
||||
case prefix != "":
|
||||
buffer.WriteString(fmt.Sprintf("&prefix=%s", url.QueryEscape(prefix)))
|
||||
fallthrough
|
||||
case delimiter != "":
|
||||
buffer.WriteString(fmt.Sprintf("&delimiter=%s", url.QueryEscape(delimiter)))
|
||||
}
|
||||
|
||||
urlReq = buffer.String()
|
||||
bres, err = c.retryRequest(urlReq)
|
||||
if err != nil {
|
||||
return nil, nil, iodine.New(err, nil)
|
||||
}
|
||||
if bres.MaxKeys != fetchN || bres.Name != bucket || bres.Marker != marker {
|
||||
msg := fmt.Sprintf("Unexpected parse from server: %#v", bres)
|
||||
err = errors.New(msg)
|
||||
return nil, nil, iodine.New(err, nil)
|
||||
}
|
||||
items, marker, err = c.getItems(startAt, marker, bres.Contents)
|
||||
if err != nil {
|
||||
return nil, nil, iodine.New(err, nil)
|
||||
}
|
||||
prefixes = (bres.CommonPrefixes)
|
||||
|
||||
if !bres.IsTruncated {
|
||||
break
|
||||
}
|
||||
|
||||
if len(items) == 0 {
|
||||
return nil, nil, iodine.New(errors.New("No items replied"), nil)
|
||||
}
|
||||
}
|
||||
sort.Sort(bySize(items))
|
||||
return items, prefixes, nil
|
||||
}
|
||||
@@ -114,8 +114,8 @@ func GetNewClient(auth *Auth, urlStr string, transport http.RoundTripper) client
|
||||
// storage implementation.
|
||||
func (c *s3Client) bucketURL(bucket string) string {
|
||||
var url string
|
||||
|
||||
// TODO: Bucket names can contain ".". This second check should be removed.
|
||||
// when minio server supports buckets with "."
|
||||
if IsValidBucketName(bucket) && !strings.Contains(bucket, ".") {
|
||||
// if localhost use PathStyle
|
||||
if strings.Contains(c.Host, "localhost") || strings.Contains(c.Host, "127.0.0.1") {
|
||||
@@ -156,7 +156,7 @@ func newReq(url string) *http.Request {
|
||||
return req
|
||||
}
|
||||
|
||||
func parseListAllMyBuckets(r io.Reader) ([]*client.Bucket, error) {
|
||||
func listAllMyBuckets(r io.Reader) ([]*client.Bucket, error) {
|
||||
type allMyBuckets struct {
|
||||
Buckets struct {
|
||||
Bucket []*client.Bucket
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/clbanning/mxj"
|
||||
"github.com/minio-io/iodine"
|
||||
)
|
||||
|
||||
/* **** SAMPLE ERROR RESPONSE ****
|
||||
@@ -49,7 +50,7 @@ func NewError(res *http.Response) error {
|
||||
s3Err.res = res
|
||||
s3Err.resMsg, err = mxj.NewMapXmlReader(res.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
return s3Err
|
||||
}
|
||||
|
||||
+17
-15
@@ -51,6 +51,8 @@ import (
|
||||
"encoding/hex"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/minio-io/iodine"
|
||||
)
|
||||
|
||||
/// Object API operations
|
||||
@@ -64,55 +66,55 @@ func (c *s3Client) Put(bucket, key, md5HexString string, size int64, contents io
|
||||
req.Body = ioutil.NopCloser(contents)
|
||||
md5, err := hex.DecodeString(md5HexString)
|
||||
if err != nil {
|
||||
return err
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
req.Header.Set("Content-MD5", base64.StdEncoding.EncodeToString(md5))
|
||||
c.signRequest(req, c.Host)
|
||||
|
||||
res, err := c.Transport.RoundTrip(req)
|
||||
if err != nil {
|
||||
return err
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return NewError(res)
|
||||
return iodine.New(NewError(res), nil)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stat - returns 0, "", os.ErrNotExist if not on S3
|
||||
func (c *s3Client) Stat(bucket, key string) (size int64, date time.Time, reterr error) {
|
||||
func (c *s3Client) StatObject(bucket, key string) (size int64, date time.Time, reterr error) {
|
||||
if bucket == "" || key == "" {
|
||||
return 0, date, os.ErrNotExist
|
||||
return 0, date, iodine.New(os.ErrNotExist, nil)
|
||||
}
|
||||
req := newReq(c.keyURL(bucket, key))
|
||||
req.Method = "HEAD"
|
||||
c.signRequest(req, c.Host)
|
||||
res, err := c.Transport.RoundTrip(req)
|
||||
if err != nil {
|
||||
return 0, date, err
|
||||
return 0, date, iodine.New(err, nil)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
switch res.StatusCode {
|
||||
case http.StatusNotFound:
|
||||
return 0, date, os.ErrNotExist
|
||||
return 0, date, iodine.New(os.ErrNotExist, nil)
|
||||
case http.StatusOK:
|
||||
size, err = strconv.ParseInt(res.Header.Get("Content-Length"), 10, 64)
|
||||
if err != nil {
|
||||
return 0, date, err
|
||||
return 0, date, iodine.New(err, nil)
|
||||
}
|
||||
if dateStr := res.Header.Get("Last-Modified"); dateStr != "" {
|
||||
// AWS S3 uses RFC1123 standard for Date in HTTP header, unlike XML content
|
||||
date, err := time.Parse(time.RFC1123, dateStr)
|
||||
if err != nil {
|
||||
return 0, date, err
|
||||
return 0, date, iodine.New(err, nil)
|
||||
}
|
||||
return size, date, nil
|
||||
}
|
||||
default:
|
||||
return 0, date, NewError(res)
|
||||
return 0, date, iodine.New(NewError(res), nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -123,11 +125,11 @@ func (c *s3Client) Get(bucket, key string) (body io.ReadCloser, size int64, md5
|
||||
c.signRequest(req, c.Host)
|
||||
res, err := c.Transport.RoundTrip(req)
|
||||
if err != nil {
|
||||
return nil, 0, "", err
|
||||
return nil, 0, "", iodine.New(err, nil)
|
||||
}
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return nil, 0, "", NewError(res)
|
||||
return nil, 0, "", iodine.New(NewError(res), nil)
|
||||
}
|
||||
md5sum := strings.Trim(res.Header.Get("ETag"), "\"") // trim off the erroneous double quotes
|
||||
return res.Body, res.ContentLength, md5sum, nil
|
||||
@@ -137,7 +139,7 @@ func (c *s3Client) Get(bucket, key string) (body io.ReadCloser, size int64, md5
|
||||
// If length is negative, the rest of the object is returned.
|
||||
func (c *s3Client) GetPartial(bucket, key string, offset, length int64) (body io.ReadCloser, size int64, md5 string, err error) {
|
||||
if offset < 0 {
|
||||
return nil, 0, "", errors.New("invalid negative offset")
|
||||
return nil, 0, "", iodine.New(errors.New("invalid negative offset"), nil)
|
||||
}
|
||||
req := newReq(c.keyURL(bucket, key))
|
||||
if length >= 0 {
|
||||
@@ -149,13 +151,13 @@ func (c *s3Client) GetPartial(bucket, key string, offset, length int64) (body io
|
||||
|
||||
res, err := c.Transport.RoundTrip(req)
|
||||
if err != nil {
|
||||
return nil, 0, "", err
|
||||
return nil, 0, "", iodine.New(err, nil)
|
||||
}
|
||||
|
||||
switch res.StatusCode {
|
||||
case http.StatusOK, http.StatusPartialContent:
|
||||
return res.Body, res.ContentLength, res.Header.Get("ETag"), nil
|
||||
default:
|
||||
return nil, 0, "", NewError(res)
|
||||
return nil, 0, "", iodine.New(NewError(res), nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/minio-io/iodine"
|
||||
)
|
||||
|
||||
// Only generic HTTP S3 fields are validated using this mechanism. S3
|
||||
@@ -54,12 +56,11 @@ Example AWS S3 Request / Response
|
||||
|
||||
// HTTP S3 request validator.
|
||||
func (t s3Verify) Request(req *http.Request) error {
|
||||
|
||||
if req.Header.Get("Authorization") == "" {
|
||||
return errors.New("Client request header has authorization key")
|
||||
return iodine.New(errors.New("Client request header has authorization key"), nil)
|
||||
}
|
||||
if !strings.HasPrefix(req.Header.Get("Authorization"), "AWS") {
|
||||
return errors.New("Client request header has malformed authorization key")
|
||||
return iodine.New(errors.New("Client request header has malformed authorization key"), nil)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
|
||||
"github.com/minio-io/iodine"
|
||||
)
|
||||
|
||||
// Trace - tracing structure
|
||||
@@ -58,7 +60,7 @@ func (t Trace) Request(req *http.Request) (err error) {
|
||||
}
|
||||
|
||||
req.Header.Set("Authorization", origAuthKey)
|
||||
return err
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
|
||||
// Response - Trace HTTP Response
|
||||
@@ -67,7 +69,7 @@ func (t Trace) Response(res *http.Response) (err error) {
|
||||
if err == nil {
|
||||
t.print(resTrace)
|
||||
}
|
||||
return err
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
|
||||
// print HTTP Response
|
||||
|
||||
Reference in New Issue
Block a user