vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Tue Feb 13 13:53:25 2018 +0100| [d0e2dabd47e00854a39ee86a0fbe1b03c9ea86c7] | committer: Francois Cartegnie
demux: adaptive: properly handle redirection (cherry picked from commit 6c36897f7d9e8585af1a1dd0c713892a57e4a690) > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=d0e2dabd47e00854a39ee86a0fbe1b03c9ea86c7 --- modules/demux/adaptive/http/Chunk.cpp | 46 ++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/modules/demux/adaptive/http/Chunk.cpp b/modules/demux/adaptive/http/Chunk.cpp index 9094322822..5dad106e1a 100644 --- a/modules/demux/adaptive/http/Chunk.cpp +++ b/modules/demux/adaptive/http/Chunk.cpp @@ -212,34 +212,46 @@ bool HTTPChunkSource::prepare(int i_redir) if(!connManager) return false; - if(!connection) + ConnectionParams connparams = params; /* can be changed on 301 */ + + while(i_redir++ < 3) { - connection = connManager->getConnection(params); if(!connection) - return false; - } + { + connection = connManager->getConnection(connparams); + if(!connection) + break; + } - int i_ret = connection->request(params.getPath(), bytesRange); - if(i_ret != VLC_SUCCESS) - { - if(i_ret == VLC_ETIMEOUT && i_redir < 3) + int i_ret = connection->request(connparams.getPath(), bytesRange); + if(i_ret != VLC_SUCCESS) { - connection->setUsed(false); - connection = NULL; - return HTTPChunkSource::prepare(i_redir + 1); + if(i_ret == VLC_ETIMEOUT) /* redirection */ + { + HTTPConnection *httpconn = dynamic_cast<HTTPConnection *>(connection); + if(httpconn) + connparams = httpconn->getRedirection(); + connection->setUsed(false); + connection = NULL; + if(httpconn) + continue; + } + break; } - return false; + + /* Because we don't know Chunk size at start, we need to get size + from content length */ + contentLength = connection->getContentLength(); + prepared = true; + return true; } - /* Because we don't know Chunk size at start, we need to get size - from content length */ - contentLength = connection->getContentLength(); - prepared = true; - return true; + return false; } block_t * HTTPChunkSource::readBlock() { + printf("READ\n"); return read(HTTPChunkSource::CHUNK_SIZE); } _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits