[FFmpeg-devel] [Fwd: http redirect with relative location fails to play with ffplay - patch]
sashas
solganik at gmail.com
Thu Apr 5 18:08:39 CEST 2012
Hi All. There is a sort of a bug in ffmpeg, in libavformat/http.c,
when 302 redirect is returned from the server, where "location"
responce header contains relative location. Though this violated HTTP
RFC specification, which states :
Quote
"The Location response-header field is used to redirect the recipient to
a location other than the Request-URI for completion of the request or
identification of a new resource. For 201 (Created) responses, the
Location is that of the new resource which was created by the request.
For 3xx responses, the location SHOULD indicate the server's preferred
URI for automatic redirection to the resource. The field value consists
of a single absolute URI.
Location = "Location" ":" absoluteURI
An example is:
Location: http://www.w3.org/pub/WWW/People.html
Note: The Content-Location header field (section 14.14) differs
from Location in that the Content-Location identifies the original
location of the entity enclosed in the request. It is therefore
possible for a response to contain header fields for both Location
and Content-Location. Also see section 13.10 for cache
requirements of some methods.
"
As you can see Location header is specified to contain absolute Uri.
But web-browsers and other media players such as VLC deal with this situation.
here is the code from VLC:
/modules/access/http.c
"
else if( !strcasecmp( psz, "Location" ) )
{
char * psz_new_loc;
/* This does not follow RFC 2068, but yet if the url is not absolute,
* handle it as everyone does. */
if( p[0] == '/' )
{
const char *psz_http_ext = p_sys->b_ssl ? "s" : "" ;
if( p_sys->url.i_port == ( p_sys->b_ssl ? 443 : 80 ) )
{
if( asprintf(&psz_new_loc, "http%s://%s%s", psz_http_ext,
p_sys->url.psz_host, p) < 0 )
goto error;
}
else
{
if( asprintf(&psz_new_loc, "http%s://%s:%d%s", psz_http_ext,
p_sys->url.psz_host, p_sys->url.i_port, p) < 0 )
goto error;
}
}"
Bug can be reproduced with the following uri:
./ffplay http://cdnbakmi.kaltura.com/p/934661/sp/93466100/raw/entry_id/1_u1pq98qx/version/0
here is CURL output of the URL with its redirects
curl -I http://cdnbakmi.kaltura.com/p/934661/sp/93466100/raw/entry_id/1_u1pq98qx/version/0
HTTP/1.1 302 Moved Temporarily
Server: Apache
X-Kaltura: access-control:
Content-Disposition: attachment; filename="Sample Big Buck Bunny Trailer (HD)"
Location: http://38.102.153.132/p/934661/sp/93466100/raw/entry_id/1_u1pq98qx/version/0
X-Me: ny-apache5
X-UA-Compatible: IE=EmulateIE7
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Expires: Thu, 05 Apr 2012 15:45:12 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Thu, 05 Apr 2012 15:45:12 GMT
Connection: keep-alive
curl -I http://38.102.153.132/p/934661/sp/93466100/raw/entry_id/1_u1pq98qx/version/0
HTTP/1.1 302 Found
Date: Thu, 05 Apr 2012 15:45:29 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Kaltura: access-control:
Content-Disposition: attachment; filename="Sample Big Buck Bunny Trailer (HD)"
Location: /p/934661/sp/93466100/raw/entry_id/1_u1pq98qx/version/0/Sample-Big-Buck-Bunny-Trailer-HD.flv?relocate=f.flv
X-Me: pa-apache5
X-UA-Compatible: IE=EmulateIE7
Content-Type: text/html; charset=UTF-8
Note that the location of the second reply is relative.
Attached proposed patch to fix this issue.
Thanks,
Regards Sasha.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: relative_redirect.patch
Type: text/x-patch
Size: 1558 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120405/ed14d125/attachment.bin>
More information about the ffmpeg-devel
mailing list