When I debug in the following code, sometimes it can read data from the body correctly but with EOF error.
func (r *trailerReader) Read(b []byte) (int, error) {
n, err := r.resp.Body.Read(b)
if err != nil {
if e := r.resp.Trailer.Get("X-Stream-Error"); e != "" {
err = errors.New(e)
}
}
return n, err
}
I called this method in my code:
// FilesRead read a file in a given MFS
func (s *Shell) FilesRead(ctx context.Context, path string, options ...FilesOpt) (io.ReadCloser, error) {
rb := s.Request("files/read", path)
for _, opt := range options {
if err := opt(rb); err != nil {
return nil, err
}
}
resp, err := rb.Send(ctx)
if err != nil {
return nil, err
}
if resp.Error != nil {
return nil, resp.Error
}
return resp.Output, nil
}
Any thoughts?