page.c: Do not get filename on previews
This change should provide the same behaviour, but would avoid unnecessary calls to dynstr_append and basename(3) when a preview is to be served.
This commit is contained in:
parent
fb8896bccd
commit
b4572c6217
18
page.c
18
page.c
|
@ -1305,7 +1305,15 @@ static int serve_file(struct http_response *const r,
|
||||||
dynstr_init(&b);
|
dynstr_init(&b);
|
||||||
dynstr_init(&d);
|
dynstr_init(&d);
|
||||||
|
|
||||||
if (dynstr_append(&b, "%s", res))
|
if (preview)
|
||||||
|
{
|
||||||
|
if (dynstr_append(&d, "inline"))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: dynstr_append inline failed\n", __func__);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dynstr_append(&b, "%s", res))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: dynstr_append res failed\n", __func__);
|
fprintf(stderr, "%s: dynstr_append res failed\n", __func__);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -1315,14 +1323,6 @@ static int serve_file(struct http_response *const r,
|
||||||
fprintf(stderr, "%s: basename(3) failed\n", __func__);
|
fprintf(stderr, "%s: basename(3) failed\n", __func__);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
else if (preview)
|
|
||||||
{
|
|
||||||
if (dynstr_append(&d, "inline"))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: dynstr_append inline failed\n", __func__);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (dynstr_append(&d, "attachment; filename=\"%s\"", bn))
|
else if (dynstr_append(&d, "attachment; filename=\"%s\"", bn))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: dynstr_append attachment failed\n", __func__);
|
fprintf(stderr, "%s: dynstr_append attachment failed\n", __func__);
|
||||||
|
|
Loading…
Reference in New Issue