()
| 46 | } |
| 47 | |
| 48 | func (b *bufferPool) Get() []byte { |
| 49 | buf := b.pool.Get() |
| 50 | if buf == nil { |
| 51 | // Use the default buffer size as defined in the ReverseProxy itself. |
| 52 | return make([]byte, 32*1024) |
| 53 | } |
| 54 | |
| 55 | buffer, ok := buf.(*[]byte) |
| 56 | if !ok { |
| 57 | panic("Failed to get buffer") // TODO: François Costa, is it the best way of doing? |
| 58 | } |
| 59 | |
| 60 | return *buffer |
| 61 | } |
| 62 | |
| 63 | // Put returns the given Buffer to the bufferPool. |
| 64 | func (b *bufferPool) Put(buffer []byte) { |