Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0911294

Browse files
author
YangSen-qn
committedApr 1, 2025·
version to 7.25.3
1 parent 64dfef8 commit 0911294

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed
 

‎CHANGELOG.md

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package api
22

33
import (
44
"bytes"
5+
"fmt"
56
"io"
67
"net/http"
78

@@ -13,7 +14,14 @@ func BytesFromRequest(r *http.Request) ([]byte, error) {
1314
if bytesNopCloser, ok := r.Body.(*internal_io.BytesNopCloser); ok {
1415
return bytesNopCloser.Bytes(), nil
1516
}
16-
buf := bytes.NewBuffer(make([]byte, 0, int(r.ContentLength)+1024))
17+
18+
// 不能大于10G
19+
if r.ContentLength > 1024*1024*1024*10 {
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)
Please sign in to comment.