|
|
@ -27,8 +27,8 @@ type dataProvider struct {
|
|
|
|
func (dp *dataProvider) Read(buf []byte) (n int, err error) {
|
|
|
|
func (dp *dataProvider) Read(buf []byte) (n int, err error) {
|
|
|
|
dp.lock.Lock()
|
|
|
|
dp.lock.Lock()
|
|
|
|
defer dp.lock.Unlock()
|
|
|
|
defer dp.lock.Unlock()
|
|
|
|
n, err = dp.buf.Read(buf)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n, err = dp.buf.Read(buf)
|
|
|
|
if err != nil && !dp.closed {
|
|
|
|
if err != nil && !dp.closed {
|
|
|
|
return 0, errAgain
|
|
|
|
return 0, errAgain
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -95,11 +95,8 @@ func (bp *bodyProvider) Write(buf []byte) (int, error) {
|
|
|
|
|
|
|
|
|
|
|
|
// Close end to provide data
|
|
|
|
// Close end to provide data
|
|
|
|
func (bp *bodyProvider) Close() error {
|
|
|
|
func (bp *bodyProvider) Close() error {
|
|
|
|
/*
|
|
|
|
bp.lock.Lock()
|
|
|
|
if c, ok := bp.w.(io.Closer); ok{
|
|
|
|
defer bp.lock.Unlock()
|
|
|
|
return c.Close()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
bp.closed = true
|
|
|
|
bp.closed = true
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|