Account for user configured small io write buffer. (#2092)
diff --git a/transport/http_util.go b/transport/http_util.go
index a355866..835c812 100644
--- a/transport/http_util.go
+++ b/transport/http_util.go
@@ -531,10 +531,14 @@
if w.err != nil {
return 0, w.err
}
- n = copy(w.buf[w.offset:], b)
- w.offset += n
- if w.offset >= w.batchSize {
- err = w.Flush()
+ for len(b) > 0 {
+ nn := copy(w.buf[w.offset:], b)
+ b = b[nn:]
+ w.offset += nn
+ n += nn
+ if w.offset >= w.batchSize {
+ err = w.Flush()
+ }
}
return n, err
}