Skip to content

Commit

Permalink
Merge pull request #1011 from glennguy/backport-padding-fix
Browse files Browse the repository at this point in the history
[Backport] Don't do PKCS7 stripping on chunked transfers
  • Loading branch information
glennguy committed Jun 23, 2022
2 parents 1c0d657 + eebfad4 commit 6c54634
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,12 @@ bool KodiAdaptiveStream::download(const char* url,
// read the file
char* buf = (char*)malloc(32 * 1024);
size_t nbReadOverall = 0;
while ((nbRead = file.Read(buf, 32 * 1024)) > 0 && ~nbRead && write_data(buf, nbRead, file.AtEnd()))
std::string transferEncodingStr{
file.GetPropertyValue(ADDON_FILE_PROPERTY_RESPONSE_HEADER, "Transfer-Encoding")};
bool isChunked{transferEncodingStr.find("hunked") != std::string::npos};

while ((nbRead = file.Read(buf, 32 * 1024)) > 0 && ~nbRead &&
write_data(buf, nbRead, (!isChunked && file.AtEnd())))
nbReadOverall += nbRead;
free(buf);

Expand Down

0 comments on commit 6c54634

Please sign in to comment.