(buf []byte, callback ReaderFunc)
| 45 | } |
| 46 | |
| 47 | func (this *MemoryReader) ReadHeader(buf []byte, callback ReaderFunc) error { |
| 48 | l := len(buf) |
| 49 | if l == 0 { |
| 50 | return errors.New("using empty buffer") |
| 51 | } |
| 52 | |
| 53 | size := len(this.item.HeaderValue) |
| 54 | offset := 0 |
| 55 | for { |
| 56 | left := size - offset |
| 57 | if l <= left { |
| 58 | copy(buf, this.item.HeaderValue[offset:offset+l]) |
| 59 | goNext, e := callback(l) |
| 60 | if e != nil { |
| 61 | return e |
| 62 | } |
| 63 | if !goNext { |
| 64 | break |
| 65 | } |
| 66 | } else { |
| 67 | copy(buf, this.item.HeaderValue[offset:]) |
| 68 | _, e := callback(left) |
| 69 | if e != nil { |
| 70 | return e |
| 71 | } |
| 72 | break |
| 73 | } |
| 74 | offset += l |
| 75 | if offset >= size { |
| 76 | break |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | func (this *MemoryReader) ReadBody(buf []byte, callback ReaderFunc) error { |
| 84 | l := len(buf) |
no outgoing calls