Permalink
Browse files

Fix reads from Transfer-Encoding: chunked servers.

There's no Content-Length in this mode, so GetLength() returns 0.
  • Loading branch information...
1 parent 254e055 commit d05fa355ca82679b0d9da6297fbfea8e51c02e82 @zewt committed Jul 22, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 xbmc/addons/Repository.cpp
@@ -92,13 +92,16 @@ CStdString CRepository::FetchChecksum(const CStdString& url)
CSingleLock lock(m_critSection);
CFile file;
file.Open(url);
- CStdString checksum;
try
{
- char* temp = checksum.GetBufferSetLength((int)file.GetLength());
- file.Read(temp,file.GetLength());
- checksum.ReleaseBuffer();
- return checksum;
+ // we intentionally avoid using file.GetLength() for
+ // Transfer-Encoding: chunked servers.
+ std::stringstream str;
+ char temp[1024];
+ int read;
+ while ((read=file.Read(temp, sizeof(temp))) > 0)
+ str.write(temp, read);
+ return str.str();
}
catch (...)
{

0 comments on commit d05fa35

Please sign in to comment.