in src/request/apache_multipart_buffer.c [68:100]
int fill_buffer(multipart_buffer *self)
{
int bytes_to_read, actual_read = 0;
/* shift the existing data if necessary */
if(self->bytes_in_buffer > 0 && self->buf_begin != self->buffer)
memmove(self->buffer, self->buf_begin, self->bytes_in_buffer);
self->buf_begin = self->buffer;
/* calculate the free space in the buffer */
bytes_to_read = self->bufsize - self->bytes_in_buffer;
if (bytes_to_read >= self->r->remaining) {
bytes_to_read = (int)(self->r->remaining - (apr_off_t)strlen(self->boundary));
#ifdef DEBUG
ap_log_rerror(MPB_ERROR, "mozilla 0.97 hack: '%ld'", self->r->remaining);
#endif
}
/* read the required number of bytes */
if(bytes_to_read > 0) {
char *buf = self->buffer + self->bytes_in_buffer;
actual_read = ap_get_client_block(self->r, buf, bytes_to_read);
/* update the buffer length */
if(actual_read > 0)
self->bytes_in_buffer += actual_read;
}
return actual_read;
}