char *basename;
char *str, *str0;
char range_buf[255];
- char disposition[512];
+ char *disposition = NULL;
off_t content_len, chunk;
intmax_t file_start, file_end;
void *tcp_id;
}
if(dvr_entry_verify(de, hc->hc_access, 1)) {
pthread_mutex_unlock(&global_lock);
- return HTTP_STATUS_NOT_FOUND;
+ return HTTP_STATUS_UNAUTHORIZED;
}
fname = tvh_strdupa(filename);
htsbuf_queue_init(&q, 0);
htsbuf_append_and_escape_url(&q, basename);
str = htsbuf_to_string(&q);
- snprintf(disposition, sizeof(disposition),
+ r = 50 + strlen(str0) + strlen(str);
+ disposition = alloca(r);
+ snprintf(disposition, r,
"attachment; filename=\"%s\"; filename*=UTF-8''%s",
str0, str);
htsbuf_queue_flush(&q);
free(str);
free(str0);
- } else {
- disposition[0] = 0;
}
fd = tvh_open(fname, O_RDONLY, 0);
http_send_header(hc, range ? HTTP_STATUS_PARTIAL_CONTENT : HTTP_STATUS_OK,
content, content_len, NULL, NULL, 10,
- range ? range_buf : NULL,
- disposition[0] ? disposition : NULL, NULL);
+ range ? range_buf : NULL, disposition, NULL);
ret = 0;
if(!hc->hc_no_output) {