{
struct cookie *c = f->cookie;
size_t rem = c->size - c->pos;
- if (!len) return 0;
- if (len > rem) len = rem;
+ if (len > rem) {
+ len = rem;
+ f->flags |= F_EOF;
+ }
memcpy(buf, c->buf+c->pos, len);
c->pos += len;
rem -= len;
f->rend = f->buf + rem;
memcpy(f->rpos, c->buf+c->pos, rem);
c->pos += rem;
- if (!len) f->flags |= F_EOF;
return len;
}