Skip to content

Commit c3b02a6

Browse files
committed
http: change default buffer size
1 parent 94c6a75 commit c3b02a6

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

http.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,13 @@ func copyBufferWithTimeout(dst io.Writer, src io.Reader, buf []byte, readTimeout
205205
return copyBufferWithTimeoutAndFlush(dst, src, buf, readTimeout, writeTimeout, nil)
206206
}
207207

208-
// based on `io.copyBuffer` with read and write timeouts
208+
// based on `io.copyBuffer` with changes:
209+
// - default buffer 2kib
210+
// - read and write timeouts
211+
// - optional flush
209212
func copyBufferWithTimeoutAndFlush(dst io.Writer, src io.Reader, buf []byte, readTimeout time.Duration, writeTimeout time.Duration, flush func()) (written int64, err error) {
210213
if buf == nil {
211-
size := 32 * 1024
214+
size := 2048
212215
if l, ok := src.(*io.LimitedReader); ok && int64(size) > l.N {
213216
if l.N < 1 {
214217
size = 1

0 commit comments

Comments
 (0)