mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 12:10:24 +03:00
tests: Do not allow forced type asserts (#20905)
This commit is contained in:
@@ -34,6 +34,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio/internal/bpool"
|
||||
"github.com/minio/minio/internal/grid"
|
||||
"github.com/tinylib/msgp/msgp"
|
||||
|
||||
@@ -831,7 +832,7 @@ func keepHTTPReqResponseAlive(w http.ResponseWriter, r *http.Request) (resp func
|
||||
// Response not ready, write a filler byte.
|
||||
write([]byte{32})
|
||||
if canWrite {
|
||||
w.(http.Flusher).Flush()
|
||||
xhttp.Flush(w)
|
||||
}
|
||||
case err := <-doneCh:
|
||||
if err != nil {
|
||||
@@ -905,7 +906,7 @@ func keepHTTPResponseAlive(w http.ResponseWriter) func(error) {
|
||||
// Response not ready, write a filler byte.
|
||||
write([]byte{32})
|
||||
if canWrite {
|
||||
w.(http.Flusher).Flush()
|
||||
xhttp.Flush(w)
|
||||
}
|
||||
case err := <-doneCh:
|
||||
if err != nil {
|
||||
@@ -1025,7 +1026,7 @@ func streamHTTPResponse(w http.ResponseWriter) *httpStreamResponse {
|
||||
// Response not ready, write a filler byte.
|
||||
write([]byte{32})
|
||||
if canWrite {
|
||||
w.(http.Flusher).Flush()
|
||||
xhttp.Flush(w)
|
||||
}
|
||||
case err := <-doneCh:
|
||||
if err != nil {
|
||||
@@ -1043,7 +1044,7 @@ func streamHTTPResponse(w http.ResponseWriter) *httpStreamResponse {
|
||||
write(tmp[:])
|
||||
write(block)
|
||||
if canWrite {
|
||||
w.(http.Flusher).Flush()
|
||||
xhttp.Flush(w)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1051,29 +1052,23 @@ func streamHTTPResponse(w http.ResponseWriter) *httpStreamResponse {
|
||||
return &h
|
||||
}
|
||||
|
||||
var poolBuf8k = sync.Pool{
|
||||
New: func() interface{} {
|
||||
var poolBuf8k = bpool.Pool[*[]byte]{
|
||||
New: func() *[]byte {
|
||||
b := make([]byte, 8192)
|
||||
return &b
|
||||
},
|
||||
}
|
||||
|
||||
var poolBuf128k = sync.Pool{
|
||||
New: func() interface{} {
|
||||
b := make([]byte, 128<<10)
|
||||
return b
|
||||
},
|
||||
}
|
||||
|
||||
// waitForHTTPStream will wait for responses where
|
||||
// streamHTTPResponse has been used.
|
||||
// The returned reader contains the payload and must be closed if no error is returned.
|
||||
func waitForHTTPStream(respBody io.ReadCloser, w io.Writer) error {
|
||||
var tmp [1]byte
|
||||
// 8K copy buffer, reused for less allocs...
|
||||
bufp := poolBuf8k.Get().(*[]byte)
|
||||
bufp := poolBuf8k.Get()
|
||||
buf := *bufp
|
||||
defer poolBuf8k.Put(bufp)
|
||||
|
||||
for {
|
||||
_, err := io.ReadFull(respBody, tmp[:])
|
||||
if err != nil {
|
||||
@@ -1438,7 +1433,6 @@ func registerStorageRESTHandlers(router *mux.Router, endpointServerPools Endpoin
|
||||
}
|
||||
}
|
||||
}(endpoint)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user