2017-05-09 12:02:44 +00:00
|
|
|
package accesslog
|
|
|
|
|
|
|
|
import "io"
|
|
|
|
|
|
|
|
type captureRequestReader struct {
|
2020-01-07 19:00:05 +00:00
|
|
|
// source ReadCloser from where the request body is read.
|
2017-05-09 12:02:44 +00:00
|
|
|
source io.ReadCloser
|
2020-01-07 19:00:05 +00:00
|
|
|
// count Counts the number of bytes read (when captureRequestReader.Read is called).
|
|
|
|
count int64
|
2017-05-09 12:02:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *captureRequestReader) Read(p []byte) (int, error) {
|
|
|
|
n, err := r.source.Read(p)
|
|
|
|
r.count += int64(n)
|
|
|
|
return n, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *captureRequestReader) Close() error {
|
|
|
|
return r.source.Close()
|
|
|
|
}
|