Skip to content

Commit 33a7ea2

Browse files
author
jojoliang
committed
add opt header in bucket head
1 parent 3c3a1ec commit 33a7ea2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

bucket.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,27 @@ func (s *BucketService) Delete(ctx context.Context) (*Response, error) {
9494
return resp, err
9595
}
9696

97+
type BucketHeadOptions struct {
98+
XOptionHeader *http.Header `header:"-,omitempty" url:"-" xml:"-"`
99+
}
100+
97101
// Head Bucket请求可以确认是否存在该Bucket,是否有权限访问,Head的权限与Read一致。
98102
//
99103
// 当其存在时,返回 HTTP 状态码200;
100104
// 当无权限时,返回 HTTP 状态码403;
101105
// 当不存在时,返回 HTTP 状态码404。
102106
//
103107
// https://www.qcloud.com/document/product/436/7735
104-
func (s *BucketService) Head(ctx context.Context) (*Response, error) {
108+
func (s *BucketService) Head(ctx context.Context, opt ...*BucketHeadOptions) (*Response, error) {
109+
var hopt *BucketHeadOptions
110+
if len(opt) > 0 {
111+
hopt = opt[0]
112+
}
105113
sendOpt := sendOptions{
106-
baseURL: s.client.BaseURL.BucketURL,
107-
uri: "/",
108-
method: http.MethodHead,
114+
baseURL: s.client.BaseURL.BucketURL,
115+
uri: "/",
116+
method: http.MethodHead,
117+
optHeader: hopt,
109118
}
110119
resp, err := s.client.send(ctx, &sendOpt)
111120
return resp, err

0 commit comments

Comments
 (0)