mirror of
https://github.com/sheumann/hush.git
synced 2024-12-24 12:29:47 +00:00
httpd: make byte ranges which start at 0 work too. Closes 4766
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
b2d668872c
commit
8cce1b3ad8
@ -348,7 +348,7 @@ struct globals {
|
|||||||
#define range_len (G.range_len )
|
#define range_len (G.range_len )
|
||||||
#else
|
#else
|
||||||
enum {
|
enum {
|
||||||
range_start = 0,
|
range_start = -1,
|
||||||
range_end = MAXINT(off_t) - 1,
|
range_end = MAXINT(off_t) - 1,
|
||||||
range_len = MAXINT(off_t),
|
range_len = MAXINT(off_t),
|
||||||
};
|
};
|
||||||
@ -370,6 +370,7 @@ enum {
|
|||||||
#define INIT_G() do { \
|
#define INIT_G() do { \
|
||||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||||
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
|
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
|
||||||
|
IF_FEATURE_HTTPD_RANGES(range_start = -1;) \
|
||||||
bind_addr_or_port = "80"; \
|
bind_addr_or_port = "80"; \
|
||||||
index_page = index_html; \
|
index_page = index_html; \
|
||||||
file_size = -1; \
|
file_size = -1; \
|
||||||
@ -1589,10 +1590,10 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
|
|||||||
if (what == SEND_BODY /* err pages and ranges don't mix */
|
if (what == SEND_BODY /* err pages and ranges don't mix */
|
||||||
|| content_gzip /* we are sending compressed page: can't do ranges */ ///why?
|
|| content_gzip /* we are sending compressed page: can't do ranges */ ///why?
|
||||||
) {
|
) {
|
||||||
range_start = 0;
|
range_start = -1;
|
||||||
}
|
}
|
||||||
range_len = MAXINT(off_t);
|
range_len = MAXINT(off_t);
|
||||||
if (range_start) {
|
if (range_start >= 0) {
|
||||||
if (!range_end) {
|
if (!range_end) {
|
||||||
range_end = file_size - 1;
|
range_end = file_size - 1;
|
||||||
}
|
}
|
||||||
@ -1600,7 +1601,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
|
|||||||
|| lseek(fd, range_start, SEEK_SET) != range_start
|
|| lseek(fd, range_start, SEEK_SET) != range_start
|
||||||
) {
|
) {
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
range_start = 0;
|
range_start = -1;
|
||||||
} else {
|
} else {
|
||||||
range_len = range_end - range_start + 1;
|
range_len = range_end - range_start + 1;
|
||||||
send_headers(HTTP_PARTIAL_CONTENT);
|
send_headers(HTTP_PARTIAL_CONTENT);
|
||||||
@ -2168,11 +2169,11 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
|
|||||||
s += sizeof("bytes=")-1;
|
s += sizeof("bytes=")-1;
|
||||||
range_start = BB_STRTOOFF(s, &s, 10);
|
range_start = BB_STRTOOFF(s, &s, 10);
|
||||||
if (s[0] != '-' || range_start < 0) {
|
if (s[0] != '-' || range_start < 0) {
|
||||||
range_start = 0;
|
range_start = -1;
|
||||||
} else if (s[1]) {
|
} else if (s[1]) {
|
||||||
range_end = BB_STRTOOFF(s+1, NULL, 10);
|
range_end = BB_STRTOOFF(s+1, NULL, 10);
|
||||||
if (errno || range_end < range_start)
|
if (errno || range_end < range_start)
|
||||||
range_start = 0;
|
range_start = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user