mirror of https://github.com/Xhofe/alist
fix(s3): allow http/https headers to be attached from CustomHost (#2959)
* add(s3):Allow http/https headers to be attached to CustomHost * optimize Co-authored-by: wangwuxuan <wangwuxuan@163.com> Co-authored-by: Noah Hsu <i@nn.ci>pull/2964/head
parent
2f19d4a834
commit
9398cdaac1
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
"github.com/alist-org/alist/v3/internal/op"
|
"github.com/alist-org/alist/v3/internal/op"
|
||||||
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||||
"github.com/aws/aws-sdk-go/aws/request"
|
"github.com/aws/aws-sdk-go/aws/request"
|
||||||
|
@ -38,7 +39,14 @@ func (d *S3) getClient(link bool) *s3.S3 {
|
||||||
if r.HTTPRequest.Method != http.MethodGet {
|
if r.HTTPRequest.Method != http.MethodGet {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//判断CustomHost是否以http://或https://开头
|
||||||
|
split := strings.SplitN(d.CustomHost, "://", 2)
|
||||||
|
if utils.SliceContains([]string{"http", "https"}, split[0]) {
|
||||||
|
r.HTTPRequest.URL.Scheme = split[0]
|
||||||
|
r.HTTPRequest.URL.Host = split[1]
|
||||||
|
} else {
|
||||||
r.HTTPRequest.URL.Host = d.CustomHost
|
r.HTTPRequest.URL.Host = d.CustomHost
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return client
|
return client
|
||||||
|
|
Loading…
Reference in New Issue