*/
API_EXPORT(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset,
apr_size_t length, apr_size_t *nbytes);
-/**
- * Send the body of a response to the client
- * @param f The BUFF structure associated with a client
- * @param r The current request
- * @return The number of bytes sent
- * @deffunc long ap_send_fb(BUFF *f, request_rec *r)
- */
-API_EXPORT(long) ap_send_fb(BUFF *f, request_rec *r);
-/**
- * Send a specified number of bytes from the body of the response to the client
- * @param f the BUFF structure associated with a client
- * @param r The current request
- * @param length The number of bytes to send
- * @return The number of bytes sent
- * @deffunc long ap_send_fb_length(BUFF *f, request_rec *r, long length)
- */
-API_EXPORT(long) ap_send_fb_length(BUFF *f, request_rec *r, long length);
/**
* Send an MMAP'ed file to the client
* @param mm The MMAP'ed file to send
}
#endif
-/*
- * Send the body of a response to the client.
- */
-API_EXPORT(long) ap_send_fb(BUFF *fb, request_rec *r)
-{
- return ap_send_fb_length(fb, r, -1);
-}
-
-API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length)
-{
- char buf[IOBUFSIZE];
- long total_bytes_sent = 0;
- long zero_timeout = 0;
- register int o;
- apr_ssize_t n;
- apr_ssize_t bytes_read;
- apr_status_t read_rv;
-
- if (length == 0) {
- return 0;
- }
-
- /* This function tries to as much as possible through non-blocking
- * reads so that it can do writes while waiting for the CGI to
- * produce more data. This way, the CGI's output gets to the client
- * as soon as possible */
-
- ap_bsetopt(fb, BO_TIMEOUT, &zero_timeout);
- while (!r->connection->aborted) {
- read_rv = ap_bread(fb, buf, sizeof(buf), &n);
- got_read:
- bytes_read = n;
- /* Regardless of read errors, EOF, etc, bytes may have been read */
- o = ap_rwrite(buf, n, r);
- if (o < 0)
- break;
- total_bytes_sent += o;
- if (read_rv == APR_SUCCESS) {
- /* Assume a sucessful read of 0 bytes is an EOF
- * Note: I don't think this is ultimately the right thing.
- * Read functions should explicitly return EOF.
- * wgs
- */
- if (bytes_read == 0) {
- (void) ap_rflush(r);
- break;
- }
- }
- else if (read_rv == APR_EOF) {
- (void) ap_rflush(r);
- break;
- }
- else if (!APR_STATUS_IS_EAGAIN(read_rv)) {
- r->connection->aborted = 1;
- break;
- }
- else {
- /* next read will block, so flush the client now */
- if (ap_rflush(r) == EOF) {
- break;
- }
- ap_bsetopt(fb, BO_TIMEOUT, &r->server->timeout);
- read_rv = ap_bread(fb, buf, sizeof(buf), &n);
- ap_bsetopt(fb, BO_TIMEOUT, &zero_timeout);
- goto got_read;
- }
- }
- SET_BYTES_SENT(r);
- return total_bytes_sent;
-}
-
#ifdef USE_MMAP_FILES
/* The code writes MMAP_SEGMENT_SIZE bytes at a time. This is due to Apache's