mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 09:43:51 +00:00
Fix #196
This commit is contained in:
parent
7231f6fe00
commit
f40de531ab
12
httplib.h
12
httplib.h
@ -1018,10 +1018,7 @@ public:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
bool decompress(const char *data, size_t data_len, T callback) {
|
bool decompress(const char *data, size_t data_len, T callback) {
|
||||||
int ret = Z_OK;
|
int ret = Z_OK;
|
||||||
std::string decompressed;
|
|
||||||
|
|
||||||
// strm.avail_in = content.size();
|
|
||||||
// strm.next_in = (Bytef *)content.data();
|
|
||||||
strm.avail_in = data_len;
|
strm.avail_in = data_len;
|
||||||
strm.next_in = (Bytef *)data;
|
strm.next_in = (Bytef *)data;
|
||||||
|
|
||||||
@ -1039,15 +1036,10 @@ public:
|
|||||||
case Z_MEM_ERROR: inflateEnd(&strm); return false;
|
case Z_MEM_ERROR: inflateEnd(&strm); return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
decompressed.append(buff, bufsiz - strm.avail_out);
|
callback(buff, bufsiz - strm.avail_out);
|
||||||
} while (strm.avail_out == 0);
|
} while (strm.avail_out == 0);
|
||||||
|
|
||||||
if (ret == Z_STREAM_END) {
|
return ret == Z_STREAM_END;
|
||||||
callback(decompressed.data(), decompressed.size());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user