Skip to content

Commit 7e6145d

Browse files
committed
On platforms where compression is not supported, trying to use a compressor or decompressor will throw an exception
1 parent 3bcc8eb commit 7e6145d

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

Release/src/http/common/http_helpers.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,11 @@ namespace compression
642642
public:
643643
bool has_error() const
644644
{
645-
assert(false); //Compression/Decompression has not been implemented or configured on this platform
645+
//Compression/Decompression has not been implemented or configured on this platform
646+
if (!stream_compressor::is_supported())
647+
{
648+
throw std::exception();
649+
}
646650
return true;
647651
}
648652
};
@@ -651,21 +655,31 @@ namespace compression
651655
{
652656
public:
653657
stream_compressor_impl(compression_algorithm) {}
654-
compression::data_buffer compress(const uint8_t*, size_t, bool)
658+
compression::data_buffer compress(const uint8_t* data, size_t size, bool)
655659
{
656-
assert(false); //Compression is not implemented or configured on this platform
657-
return{};
660+
//Compression is not implemented or configured on this platform
661+
if (!stream_compressor::is_supported())
662+
{
663+
throw std::exception();
664+
}
665+
666+
return data_buffer(data, data + size);
658667
}
659668
};
660669

661670
class stream_decompressor::stream_decompressor_impl : public compression_base_impl
662671
{
663672
public:
664673
stream_decompressor_impl(compression_algorithm) {}
665-
compression::data_buffer decompress(const uint8_t*, size_t)
674+
compression::data_buffer decompress(const uint8_t* data, size_t size)
666675
{
667-
assert(false); //Decompression is not implemented or configured on this platform
668-
return{};
676+
//Decompression is not implemented or configured on this platform
677+
if (!stream_decompressor::is_supported())
678+
{
679+
throw std::exception();
680+
}
681+
682+
return data_buffer(data, data + size);
669683
}
670684
};
671685
#endif

0 commit comments

Comments
 (0)