Up to date
This page is up to date for Godot 4.0
. If you still find outdated information, please open an issue.
StreamPeerGZIP
Inherits: StreamPeer < RefCounted < Object
A stream peer that handles GZIP and deflate compression/decompression.
Description
This class allows to compress or decompress data using GZIP/deflate in a streaming fashion. This is particularly useful when compressing or decompressing files that have to be sent through the network without needing to allocate them all in memory.
After starting the stream via start_compression (or start_decompression), calling StreamPeer.put_partial_data on this stream will compress (or decompress) the data, writing it to the internal buffer. Calling StreamPeer.get_available_bytes will return the pending bytes in the internal buffer, and StreamPeer.get_partial_data will retrieve the compressed (or decompressed) bytes from it. When the stream is over, you must call finish to ensure the internal buffer is properly flushed (make sure to call StreamPeer.get_available_bytes on last time to check if more data needs to be read after that).
Methods
void | clear ( ) |
finish ( ) | |
start_compression ( bool use_deflate=false, int buffer_size=65535 ) | |
start_decompression ( bool use_deflate=false, int buffer_size=65535 ) |
Method Descriptions
void clear ( )
Clears this stream, resetting the internal state.
Error finish ( )
Finalizes the stream, compressing or decompressing any buffered chunk left.
Error start_compression ( bool use_deflate=false, int buffer_size=65535 )
Start the stream in compression mode with the given buffer_size
, if use_deflate
is true
uses deflate instead of GZIP.
Error start_decompression ( bool use_deflate=false, int buffer_size=65535 )
Start the stream in decompression mode with the given buffer_size
, if use_deflate
is true
uses deflate instead of GZIP.