Browse Source

[core] remove some (now) unused http_chunk APIs

remove http_chunk_append_file() and http_chunk_append_file_range()

callers should choose to use stat_cache_entry_open() for caching
or should open file and check sizes and ranges
master
Glenn Strauss 5 months ago
parent
commit
5ff9e2f6eb
  1. 37
      src/http_chunk.c
  2. 2
      src/http_chunk.h

37
src/http_chunk.c

@ -55,14 +55,6 @@ static int http_chunk_len_append_tempfile(chunkqueue * const cq, uintmax_t len,
#endif
}
static int http_chunk_append_file_open_fstat(const request_st * const r, const buffer * const fn, struct stat * const st) {
return
(r->conf.follow_symlink
|| !stat_cache_path_contains_symlink(fn, r->conf.errh))
? stat_cache_open_rdonly_fstat(fn, st, r->conf.follow_symlink)
: -1;
}
static int http_chunk_append_read_fd_range(request_st * const r, const buffer * const fn, const int fd, off_t offset, off_t len) {
/* note: this routine should not be used for range requests
* unless the total size of ranges requested is small */
@ -129,35 +121,6 @@ void http_chunk_append_file_fd_range(request_st * const r, const buffer * const
chunkqueue_append_mem(cq, CONST_STR_LEN("\r\n"));
}
int http_chunk_append_file_range(request_st * const r, const buffer * const fn, const off_t offset, off_t len) {
struct stat st;
const int fd = http_chunk_append_file_open_fstat(r, fn, &st);
if (fd < 0) return -1;
if (-1 == len) {
if (offset >= st.st_size) {
close(fd);
return (offset == st.st_size) ? 0 : -1;
}
len = st.st_size - offset;
}
else if (st.st_size - offset < len) {
close(fd);
return -1;
}
http_chunk_append_file_fd_range(r, fn, fd, offset, len);
return 0;
}
int http_chunk_append_file(request_st * const r, const buffer * const fn) {
struct stat st;
const int fd = http_chunk_append_file_open_fstat(r, fn, &st);
if (fd < 0) return -1;
http_chunk_append_file_fd(r, fn, fd, st.st_size);
return 0;
}
int http_chunk_append_file_fd(request_st * const r, const buffer * const fn, const int fd, const off_t sz) {
if (sz > 32768 || !r->resp_send_chunked) {
http_chunk_append_file_fd_range(r, fn, fd, 0, sz);

2
src/http_chunk.h

@ -13,10 +13,8 @@ int http_chunk_append_buffer(request_st *r, buffer *mem); /* may reset "mem" */
int http_chunk_decode_append_mem(request_st * const r, const char * const mem, const size_t len);
int http_chunk_decode_append_buffer(request_st * const r, buffer * const mem); /* may reset "mem" */
int http_chunk_transfer_cqlen(request_st *r, chunkqueue *src, size_t len);
int http_chunk_append_file(request_st *r, const buffer *fn); /* copies "fn" */
int http_chunk_append_file_fd(request_st *r, const buffer *fn, int fd, off_t sz);
int http_chunk_append_file_ref(request_st *r, struct stat_cache_entry *sce); /* copies "fn" */
int http_chunk_append_file_range(request_st *r, const buffer *fn, off_t offset, off_t len); /* copies "fn" */
void http_chunk_append_file_fd_range(request_st *r, const buffer *fn, int fd, off_t offset, off_t len); /* copies "fn" */
void http_chunk_append_file_ref_range(request_st *r, struct stat_cache_entry *sce, off_t offset, off_t len); /* copies "fn" */
void http_chunk_close(request_st *r);

Loading…
Cancel
Save