Skip to content

Commit 8929400

Browse files
committed
修复bucket origin布尔类型参数为false时不传递的问题
1 parent 45fe328 commit 8929400

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

bucket_origin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ type BucketOriginCondition struct {
3030

3131
type BucketOriginParameter struct {
3232
Protocol string `xml:"Protocol,omitempty"`
33-
FollowQueryString bool `xml:"FollowQueryString,omitempty"`
33+
FollowQueryString *bool `xml:"FollowQueryString,omitempty"`
3434
HttpHeader *BucketOriginHttpHeader `xml:"HttpHeader,omitempty"`
35-
FollowRedirection bool `xml:"FollowRedirection,omitempty"`
35+
FollowRedirection *bool `xml:"FollowRedirection,omitempty"`
3636
HttpRedirectCode string `xml:"HttpRedirectCode,omitempty"`
37-
CopyOriginData bool `xml:"CopyOriginData,omitempty"`
37+
CopyOriginData *bool `xml:"CopyOriginData,omitempty"`
3838
}
3939

4040
type BucketOriginHttpHeader struct {
4141
// 目前还不支持 FollowAllHeaders
42-
FollowAllHeaders bool `xml:"FollowAllHeaders,omitempty"`
42+
FollowAllHeaders *bool `xml:"FollowAllHeaders,omitempty"`
4343
NewHttpHeaders []OriginHttpHeader `xml:"NewHttpHeaders>Header,omitempty"`
4444
FollowHttpHeaders []OriginHttpHeader `xml:"FollowHttpHeaders>Header,omitempty"`
4545
ForbidFollowHeaders []OriginHttpHeader `xml:"ForbidFollowHeaders>Header,omitempty"`

bucket_origin_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestBucketService_GetOrigin(t *testing.T) {
2929
</OriginCondition>
3030
<OriginParameter>
3131
<Protocol>HTTP</Protocol>
32-
<FollowQueryString>true</FollowQueryString>
32+
<FollowQueryString>false</FollowQueryString>
3333
<HttpHeader>
3434
<NewHttpHeaders>
3535
<Header>
@@ -75,7 +75,7 @@ func TestBucketService_GetOrigin(t *testing.T) {
7575
},
7676
OriginParameter: &BucketOriginParameter{
7777
Protocol: "HTTP",
78-
FollowQueryString: true,
78+
FollowQueryString: Bool(false),
7979
HttpHeader: &BucketOriginHttpHeader{
8080
FollowHttpHeaders: []OriginHttpHeader{
8181
{
@@ -89,7 +89,7 @@ func TestBucketService_GetOrigin(t *testing.T) {
8989
},
9090
},
9191
},
92-
FollowRedirection: true,
92+
FollowRedirection: Bool(true),
9393
HttpRedirectCode: "302",
9494
},
9595
OriginInfo: &BucketOriginInfo{
@@ -123,7 +123,7 @@ func TestBucketService_PutOrigin(t *testing.T) {
123123
},
124124
OriginParameter: &BucketOriginParameter{
125125
Protocol: "HTTP",
126-
FollowQueryString: true,
126+
FollowQueryString: Bool(true),
127127
HttpHeader: &BucketOriginHttpHeader{
128128
FollowHttpHeaders: []OriginHttpHeader{
129129
{
@@ -137,7 +137,7 @@ func TestBucketService_PutOrigin(t *testing.T) {
137137
},
138138
},
139139
},
140-
FollowRedirection: true,
140+
FollowRedirection: Bool(true),
141141
HttpRedirectCode: "302",
142142
},
143143
OriginInfo: &BucketOriginInfo{

example/bucket/origin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func main() {
5858
},
5959
OriginParameter: &cos.BucketOriginParameter{
6060
Protocol: "FOLLOW",
61-
FollowQueryString: true,
61+
FollowQueryString: cos.Bool(true),
6262
HttpHeader: &cos.BucketOriginHttpHeader{
6363
NewHttpHeaders: []cos.OriginHttpHeader{
6464
{
@@ -72,7 +72,7 @@ func main() {
7272
},
7373
},
7474
},
75-
FollowRedirection: true,
75+
FollowRedirection: cos.Bool(true),
7676
},
7777
OriginInfo: &cos.BucketOriginInfo{
7878
HostInfo: &cos.BucketOriginHostInfo{

helper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,7 @@ func GetBucketRegionFromUrl(u *url.URL) (string, string) {
474474
}
475475
return vec[0], vec[2]
476476
}
477+
478+
func Bool(v bool) *bool {
479+
return &v
480+
}

0 commit comments

Comments
 (0)