[FFmpeg-devel] [Fwd: http redirect with relative location fails to play with ffplay - patch]

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu Apr 5 18:30:41 CEST 2012


On Thu, Apr 05, 2012 at 07:08:39PM +0300, sashas wrote:
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 2589a8f..e2f9f17 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -111,6 +111,7 @@ static int http_open_cnx(URLContext *h)
>      av_url_split(proto, sizeof(proto), auth, sizeof(auth),
>                   hostname, sizeof(hostname), &port,
>                   path1, sizeof(path1), s->location);
> + redo_host:
>      ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
>  
>      if (!strcmp(proto, "https")) {
> @@ -171,11 +172,20 @@ static int http_open_cnx(URLContext *h)
>          ffurl_close(hd);
>          if (redirects++ >= MAX_REDIRECTS)
>              return AVERROR(EIO);
> +

Drop this unrelated change.

>          /* Restart the authentication process with the new target, which
>           * might use a different auth mechanism. */
>          memset(&s->auth_state, 0, sizeof(s->auth_state));
>          attempts = 0;
>          location_changed = 0;
> +
> +	/* This does not follow RFC 2068, but yet if the url is not absolute,
> +        * handle it as everyone does. */
> +	if ((NULL != s->location) && ('/' == s->location[0])){

This would be more in the FFmpeg style as
if (s->location && s->location[0] == '/') {
However this handles only a small fraction of all possible relative
URLs, I _think_ we have some code somewhere that handles all cases properly,
it would be better to reuse that.
Also I very much think this really needs to print a warning about the
web server being misconfigured.


More information about the ffmpeg-devel mailing list