summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-04-29 20:18:52 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2019-05-04 13:48:22 -0400
commit470a692211a31627095fd2db1924df961139388c (patch)
treebc29ee37ca8081c6e2495a3d78ef0e198cff7b34
parent8f0adfe0439b93263f8312f55a8060a6822e8bdc (diff)
downloadlighttpd1.4-470a692211a31627095fd2db1924df961139388c.tar.gz
lighttpd1.4-470a692211a31627095fd2db1924df961139388c.zip
[core] http_chunk_append_file_fd()
-rw-r--r--src/http_chunk.c9
-rw-r--r--src/http_chunk.h1
2 files changed, 7 insertions, 3 deletions
diff --git a/src/http_chunk.c b/src/http_chunk.c
index e8717756..302e94b3 100644
--- a/src/http_chunk.c
+++ b/src/http_chunk.c
@@ -81,13 +81,16 @@ int http_chunk_append_file(server *srv, connection *con, buffer *fn) {
struct stat st;
const int fd = http_chunk_append_file_open_fstat(srv, con, fn, &st);
if (fd < 0) return -1;
+ http_chunk_append_file_fd(srv, con, fn, fd, st.st_size);
+ return 0;
+}
- if (0 != st.st_size) {
- http_chunk_append_file_fd_range(srv, con, fn, fd, 0, st.st_size);
+void http_chunk_append_file_fd(server *srv, connection *con, buffer *fn, int fd, off_t sz) {
+ if (0 != sz) {
+ http_chunk_append_file_fd_range(srv, con, fn, fd, 0, sz);
} else {
close(fd);
}
- return 0;
}
static int http_chunk_append_to_tempfile(server *srv, connection *con, const char * mem, size_t len) {
diff --git a/src/http_chunk.h b/src/http_chunk.h
index ab335257..404c3a10 100644
--- a/src/http_chunk.h
+++ b/src/http_chunk.h
@@ -8,6 +8,7 @@ int http_chunk_append_mem(server *srv, connection *con, const char * mem, size_t
int http_chunk_append_buffer(server *srv, connection *con, buffer *mem); /* may reset "mem" */
int http_chunk_transfer_cqlen(server *srv, connection *con, chunkqueue *src, size_t len);
int http_chunk_append_file(server *srv, connection *con, buffer *fn); /* copies "fn" */
+void http_chunk_append_file_fd(server *srv, connection *con, buffer *fn, int fd, off_t sz);
int http_chunk_append_file_range(server *srv, connection *con, buffer *fn, off_t offset, off_t len); /* copies "fn" */
void http_chunk_close(server *srv, connection *con);