29 lines
382 B
Go
29 lines
382 B
Go
package fastcgi
|
|
|
|
type streamReader struct {
|
|
c *FCGIClient
|
|
buf []byte
|
|
}
|
|
|
|
func (w *streamReader) Read(p []byte) (n int, err error) {
|
|
|
|
if len(p) > 0 {
|
|
if len(w.buf) == 0 {
|
|
rec := &Record{}
|
|
w.buf, err = rec.read(w.c.rwc)
|
|
if err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
n = len(p)
|
|
if n > len(w.buf) {
|
|
n = len(w.buf)
|
|
}
|
|
copy(p, w.buf[:n])
|
|
w.buf = w.buf[n:]
|
|
}
|
|
|
|
return
|
|
}
|