mirror of
https://github.com/mirror/wget.git
synced 2026-09-03 13:22:50 +08:00
Update if statement involving hs->restval http.c:2859
This commit is contained in:
35
src/http.c
35
src/http.c
@@ -1703,13 +1703,15 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
|
||||
/* ... but some HTTP/1.0 caches doesn't implement Cache-Control. */
|
||||
request_set_header (req, "Pragma", "no-cache", rel_none);
|
||||
}
|
||||
|
||||
|
||||
if(hs->restval_last)
|
||||
request_set_header (req, "Range",
|
||||
aprintf ("bytes=%s-%s",
|
||||
number_to_static_string (hs->restval),
|
||||
number_to_static_string (hs->restval_last)),
|
||||
rel_value);
|
||||
{
|
||||
request_set_header (req, "Range",
|
||||
aprintf ("bytes=%s-%s",
|
||||
number_to_static_string (hs->restval),
|
||||
number_to_static_string (hs->restval_last)),
|
||||
rel_value);
|
||||
}
|
||||
else if (hs->restval)
|
||||
request_set_header (req, "Range",
|
||||
aprintf ("bytes=%s-",
|
||||
@@ -2484,7 +2486,7 @@ read_header:
|
||||
xfree (head);
|
||||
return RETRUNNEEDED;
|
||||
}
|
||||
if ((contrange != 0 && contrange != hs->restval)
|
||||
if ((contrange != 0 && (!(hs->restval_last) && contrange != hs->restval))
|
||||
|| (H_PARTIAL (statcode) && !contrange))
|
||||
{
|
||||
/* The Range request was somehow misunderstood by the server.
|
||||
@@ -2830,10 +2832,7 @@ Spider mode enabled. Check if remote file exists.\n"));
|
||||
include cases like server failure in one of the segments. */
|
||||
/* Decide whether or not to restart. */
|
||||
if (force_full_retrieve)
|
||||
{
|
||||
hstat.restval = hstat.len;
|
||||
hstat.restval_last = 0;
|
||||
}
|
||||
else if (opt.always_rest
|
||||
&& got_name
|
||||
&& stat (hstat.local_file, &st) == 0
|
||||
@@ -2841,26 +2840,20 @@ Spider mode enabled. Check if remote file exists.\n"));
|
||||
/* When -c is used, continue from on-disk size. (Can't use
|
||||
hstat.len even if count>1 because we don't want a failed
|
||||
first attempt to clobber existing data.) */
|
||||
{
|
||||
hstat.restval = st.st_size;
|
||||
hstat.restval_last = 0;
|
||||
}
|
||||
else if (count > 1)
|
||||
{
|
||||
/* otherwise, continue where the previous try left off */
|
||||
hstat.restval = hstat.len;
|
||||
hstat.restval_last = 0;
|
||||
}
|
||||
else if (range)
|
||||
else
|
||||
hstat.restval = 0;
|
||||
|
||||
if (range)
|
||||
{
|
||||
hstat.restval = range->first_byte;
|
||||
hstat.restval_last = range -> last_byte;
|
||||
}
|
||||
else
|
||||
{
|
||||
hstat.restval = 0;
|
||||
hstat.restval_last = 0;
|
||||
}
|
||||
hstat.restval_last = 0;
|
||||
|
||||
/* Decide whether to send the no-cache directive. We send it in
|
||||
two cases:
|
||||
|
||||
@@ -1016,7 +1016,8 @@ retrieve_from_file (const char *file, bool html, int *count)
|
||||
uerr_t status, status_least_severe;
|
||||
sem_t retr_sem;
|
||||
pthread_t thread;
|
||||
int N_THREADS = 3, free_threads = N_THREADS, range_start, chunk_size,file_extension;
|
||||
int N_THREADS = 3;
|
||||
int free_threads = N_THREADS, range_start, chunk_size,file_extension;
|
||||
struct s_thread_ctx *thread_ctx = NULL;
|
||||
char *temp_name;
|
||||
|
||||
@@ -1027,7 +1028,6 @@ retrieve_from_file (const char *file, bool html, int *count)
|
||||
sem_init (&retr_sem, 0, 0);
|
||||
range_start = 0;
|
||||
chunk_size = (file->size) / N_THREADS;
|
||||
temp_name = malloc(6 + strlen(file->name));
|
||||
j = file_extension = 0;
|
||||
while((resource = file->resources[j]) != NULL)
|
||||
{
|
||||
@@ -1059,6 +1059,7 @@ retry:
|
||||
break;
|
||||
}
|
||||
|
||||
temp_name = malloc(7 + (N_THREADS/10 + 1) + strlen(file->name));
|
||||
sprintf(temp_name, "temp_%s.%d", file->name, file_extension++);
|
||||
thread_ctx[index].file = temp_name;
|
||||
thread_ctx[index].referer = NULL;
|
||||
|
||||
Reference in New Issue
Block a user