mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-12 07:23:24 -05:00
Send a Content-Length header when plainly streaming a whole file
That is, don't send a Content-Length if we're decoding a whole file, as we do not know the exact size in this case. Based on a patch by Ace Jones.
This commit is contained in:
parent
a91b1ef46e
commit
8feeecd895
15
src/httpd.c
15
src/httpd.c
@ -532,7 +532,22 @@ httpd_stream_file(struct evhttp_request *req, int id)
|
|||||||
st->req = req;
|
st->req = req;
|
||||||
|
|
||||||
if ((offset == 0) && (end_offset == 0))
|
if ((offset == 0) && (end_offset == 0))
|
||||||
|
{
|
||||||
|
/* If we are not decoding, send the Content-Length. We don't do
|
||||||
|
* that if we are decoding because we can only guesstimate the
|
||||||
|
* size in this case and the error margin is unknown and variable.
|
||||||
|
*/
|
||||||
|
if (!st->xcode)
|
||||||
|
{
|
||||||
|
ret = snprintf(buf, sizeof(buf), "%ld", st->size);
|
||||||
|
if ((ret < 0) || (ret >= sizeof(buf)))
|
||||||
|
DPRINTF(E_LOG, L_HTTPD, "Content-Length too large for buffer, dropping\n");
|
||||||
|
else
|
||||||
|
evhttp_add_header(req->output_headers, "Content-Length", buf);
|
||||||
|
}
|
||||||
|
|
||||||
evhttp_send_reply_start(req, HTTP_OK, "OK");
|
evhttp_send_reply_start(req, HTTP_OK, "OK");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user