[FFmpeg-devel] [PATCH] http: Manually return EOF at the end of the content if the server doesn't handle Connnection: close properly

Ronald S. Bultje rsbultje
Mon Aug 9 02:34:42 CEST 2010


Hi,

On Sun, Aug 8, 2010 at 6:55 AM, Martin Storsj? <martin at martin.st> wrote:
> When doing http requests, we set Connection: close as one of the
> request headers, to tell the server that it should close the connection
> after serving us the file we requested. If the server doesn't handle this
> request properly, the connection will remain open after the file has been
> served, and we block for a long while trying to read more data (when all
> data accounted for in Content-Length has been served).
>
> The attached patch checks if the server replies with a Connection: close
> header in the response header - if not, and if Content-Length was
> provided, we manually return AVERROR_EOF when we've got enough data.
>
> In principle, we could always do this as long as a content length was
> provided, but this only does it for the case where the server doesn't
> handle Connection: close.
>
> I noticed this when testing the Apple HTTP Live Streaming protocol against
> a Wowza server, that simply keeps the connection open after serving the
> file content, leading to huge delays until getting EOF for the files (when
> the server chose to time out the HTTP connection).

I think the patch is OK. It'd be nice if you could - while you're at
it - add a few doxy comments a few (at least this new one) entries in
HTTPContext, since it's getting bigger with each patch and I'd like to
keep it a bit organized. I might also at some point change all these
[0,1] ints to a flags field, but that's for later...

Ronald



More information about the ffmpeg-devel mailing list