diff --git a/src/buffer b/src/buffer index 84e1b93..1bd1b6d 160000 --- a/src/buffer +++ b/src/buffer @@ -1 +1 @@ -Subproject commit 84e1b93c110b8a886fadab0563319506edb66741 +Subproject commit 1bd1b6d192eda9e5bc24582e7ef3a4a017f9b064 diff --git a/src/connection.c b/src/connection.c index 8e8b647..3d2b452 100644 --- a/src/connection.c +++ b/src/connection.c @@ -66,6 +66,7 @@ static void conn_send_file(struct uh_connection *conn, const char *path) { struct uh_connection_internal *conni = (struct uh_connection_internal *)conn; struct stat st; + int ret; conni->file.fd = open(path, O_RDONLY); @@ -73,6 +74,10 @@ static void conn_send_file(struct uh_connection *conn, const char *path) conni->file.size = st.st_size; + /* If the file is not greater than 8K, then append it to the HTTP head, send once */ + ret = buffer_put_fd(&conni->wb, conni->file.fd, 8192, NULL); + conni->file.size -= ret; + ev_io_start(conni->srv->loop, &conni->iow); }