I got data from web server:
data := '
HTTP/1.1 200 OK
Content-Encoding: gzip
Vary: Accept-Encoding
Content-type: text/html
Transfer-Encoding: chunked
Server: Apache
3d5
????????????????????????????????????
????????????????????????????????????
????????????????????????????????????
';
The size of data is: 3d5 (in hex)
all is stored to TIdBytes variable “data”.
How to decode gziped data, change something in it, and encode back and edit the length 3d5 to new.
The
Transfer-Encodingresponse header is set tochunked. That means the server sends the body data in chunks, where each chunk indicates its own size, where a 0-length chunk indicates the end of the data. The3d5refers to the size of the first chunk. That would be the full size of the HTML only if there is just 1 chunk of data in the response.TIdHTTPinternally handles chunked data for you. If the de-chunked data has been gzip’ped,TIdHTTPcan decompress it for you if you assign aTIdZLibCompressorBase-derived component, such asTIdCompressorZLib, to theTIdHTTP.Compressorproperty beforehand.