Skip to content

Commit

Permalink
http: stream file slices
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Feb 1, 2025
1 parent 48a746e commit 0db33d8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions fio-stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46962,8 +46962,17 @@ FIO_SFUNC void fio___http_controller_http1_write_body(
return;
}
} else if ((uint32_t)(args.fd + 1) > 1U) { /* File? */
if (!args.len) { /* TODO: collect remaining file length */
goto no_length_err;
if (!args.len) {
if (fio_fd_type(args.fd) != S_IFREG)
goto no_length_err;
/* collect remaining file length */
off_t len = fio_fd_size(args.fd);
off_t offset = lseek(args.fd, 0, SEEK_CUR);
if (len > 0 && offset > 0)
len -= offset;
if (len <= 0)
goto no_length_err;
args.len = (size_t)len;
}
FIO_STR_INFO_TMP_VAR(buf, 32);
if (c->state.http.buf.buf)
Expand Down
13 changes: 11 additions & 2 deletions fio-stl/439 http.h
Original file line number Diff line number Diff line change
Expand Up @@ -1500,8 +1500,17 @@ FIO_SFUNC void fio___http_controller_http1_write_body(
return;
}
} else if ((uint32_t)(args.fd + 1) > 1U) { /* File? */
if (!args.len) { /* TODO: collect remaining file length */
goto no_length_err;
if (!args.len) {
if (fio_fd_type(args.fd) != S_IFREG)
goto no_length_err;
/* collect remaining file length */
off_t len = fio_fd_size(args.fd);
off_t offset = lseek(args.fd, 0, SEEK_CUR);
if (len > 0 && offset > 0)
len -= offset;
if (len <= 0)
goto no_length_err;
args.len = (size_t)len;
}
FIO_STR_INFO_TMP_VAR(buf, 32);
if (c->state.http.buf.buf)
Expand Down

0 comments on commit 0db33d8

Please sign in to comment.