#1 2018-04-26 15:16:15

cybexr
Member
Registered: 2016-09-14
Posts: 81

Is there some convenient funcs to deal with Transfer-Encoding: chunked

use THttpClientSocket / TWinhttp to grab some html-content, but response is chunked.
searched in syncommons.pas & syncrtsock.pas without any clue, any hint? thank you !

Offline

#2 2018-04-27 02:58:33

cybexr
Member
Registered: 2016-09-14
Posts: 81

Re: Is there some convenient funcs to deal with Transfer-Encoding: chunked

Got it , SynCommons.IsContentCompressed   SynZip.CompressGZip can do it.

Offline

#3 2018-04-27 08:03:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Is there some convenient funcs to deal with Transfer-Encoding: chunked

IIRC there is no unchunking method in the framework yet.

The "chunk" in SynZip is not the HTML chunk, it is a proprietary compression mechanism added to ZIP, working on binary blocks/chunks of 64KB.

Offline

#4 2018-04-28 02:49:33

cybexr
Member
Registered: 2016-09-14
Posts: 81

Re: Is there some convenient funcs to deal with Transfer-Encoding: chunked

Do some research again, there are some misleading in my answer.  ab you are right, The framework has no strip chunked logic.  But the winhttp has. 

https://stackoverflow.com/questions/251 … tpreaddata
https://msdn.microsoft.com/en-us/librar … 2147217396
Starting in Windows Vista and Windows Server 2008, WinHttp enables applications to perform chunked transfer encoding on data sent to the server. When the Transfer-Encoding header is present on the WinHttp response, WinHttpReadData strips the chunking information before giving the data to the application.

API-WinHttpReadData() auto strip the chunked-response, then send the data to application. Only when we wants to send chunked request, some manually code is needed before we call WinHttpSendRequest().

So my last correct output is a coincidence, winhttp does it. then CompressGZip() can decompress correctly.

Offline

Board footer

Powered by FluxBB