Skip to content

Commit 25a2c77

Browse files
author
YangSen-qn
committed
version to 7.25.3
1 parent 64dfef8 commit 25a2c77

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Changelog
2+
## 7.25.3
3+
4+
* 修复
5+
* 分片上传请求头增加 Content-Length
6+
27

38
## 7.25.2
49

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ github.com/qiniu/go-sdk
1717
在您的项目中的 `go.mod` 文件内添加这行代码
1818

1919
```
20-
require github.com/qiniu/go-sdk/v7 v7.25.2
20+
require github.com/qiniu/go-sdk/v7 v7.25.3
2121
```
2222

2323
并且在项目中使用 `"github.com/qiniu/go-sdk/v7"` 引用 Qiniu Go SDK。

conf/conf.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"github.com/qiniu/go-sdk/v7/internal/env"
55
)
66

7-
const Version = "7.25.1"
7+
const Version = "7.25.3"
88

99
const (
1010
CONTENT_TYPE_JSON = "application/json"

internal/clientv2/request.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func NewRequest(options RequestParams) (req *http.Request, err error) {
100100
if contentLengthHeaderValue := options.Header.Get("Content-Length"); contentLengthHeaderValue != "" {
101101
contentLength, err = strconv.ParseInt(contentLengthHeaderValue, 10, 64)
102102
if err != nil {
103-
return nil, fmt.Errorf("invalid Content-Length header value: %s, %w", contentLengthHeaderValue, err)
103+
return nil, fmt.Errorf("invalid Content-Length header value: %s, %s", contentLengthHeaderValue, err)
104104
}
105105
}
106106
if options.OnRequestProgress != nil {

types.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package api
22

33
import (
44
"bytes"
5+
"fmt"
56
"io"
7+
"math"
68
"net/http"
79

810
internal_io "github.com/qiniu/go-sdk/v7/internal/io"
@@ -13,7 +15,13 @@ func BytesFromRequest(r *http.Request) ([]byte, error) {
1315
if bytesNopCloser, ok := r.Body.(*internal_io.BytesNopCloser); ok {
1416
return bytesNopCloser.Bytes(), nil
1517
}
16-
buf := bytes.NewBuffer(make([]byte, 0, int(r.ContentLength)+1024))
18+
19+
if r.ContentLength > int64(math.MaxInt) {
20+
return nil, fmt.Errorf("content length too large:%d", r.ContentLength)
21+
}
22+
23+
contentLength := int(r.ContentLength) + 1024
24+
buf := bytes.NewBuffer(make([]byte, 0, contentLength))
1725
_, err := io.Copy(buf, r.Body)
1826
if err != nil {
1927
return nil, err

0 commit comments

Comments
 (0)