NewBufferPool creates a new BufferPool. This is only safe to use in the context of a httputil.ReverseProxy, as the buffers returned via Put are not cleaned explicitly.
()
| 37 | // of a httputil.ReverseProxy, as the buffers returned via Put are not cleaned |
| 38 | // explicitly. |
| 39 | func NewBufferPool() httputil.BufferPool { |
| 40 | return &bufferPool{ |
| 41 | // We don't use the New function of sync.Pool here to avoid an unnecessary |
| 42 | // allocation when creating the slices. They are implicitly created in the |
| 43 | // Get function below. |
| 44 | pool: &sync.Pool{}, |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func (b *bufferPool) Get() []byte { |
| 49 | buf := b.pool.Get() |