Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TIdHTTP handling of AcceptEncoding gzip, deflate


This question is answered.


Permlink Replies: 2 - Last Post: Nov 16, 2015 1:31 PM Last Post By: Remy Lebeau (Te...
Sean Hoffman

Posts: 126
Registered: 3/28/99
TIdHTTP handling of AcceptEncoding gzip, deflate  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 15, 2015 6:00 AM
Hey folks, just wondering does anyone know if Indy automatically handle gzip, deflate? Meaning, if I do the following:

shared_ptr<TIdHTTP> request( new TIdHTTP( NULL ) );
 
request->Request->Accept                =	"*/*";
request->Request->AcceptEncoding   =	"gzip, deflate";
 
String response = request->Get( L"http://mywebserver" );


Will "response" be the uncompressed, deflated content?
Sean Hoffman

Posts: 126
Registered: 3/28/99
Re: TIdHTTP handling of AcceptEncoding gzip, deflate  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 15, 2015 7:43 AM   in response to: Sean Hoffman in response to: Sean Hoffman
Sean Hoffman wrote:
Hey folks, just wondering does anyone know if Indy automatically handle gzip, deflate? Meaning, if I do the following:

shared_ptr<TIdHTTP> request( new TIdHTTP( NULL ) );
 
request->Request->Accept                =	"*/*";
request->Request->AcceptEncoding   =	"gzip, deflate";
 
String response = request->Get( L"http://mywebserver" );


Will "response" be the uncompressed, deflated content?

After further reading of the docs, I see that I need to assign something to the TIdHTTP->Compressor property in order to handle the compression. After I get it working, I'll post a sample in case anyone else doesn't know the answer. After including IdZlib.hpp I'm getting a bunch of "reference to gz_header is ambiguous" (and similar) errors when I compile using 32 bit clang.

...andddd the answer to zlib issue has been described here: https://forums.embarcadero.com/thread.jspa?threadID=116471

(Thanks Remy!)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TIdHTTP handling of AcceptEncoding gzip, deflate
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 16, 2015 1:31 PM   in response to: Sean Hoffman in response to: Sean Hoffman
Sean wrote:

Hey folks, just wondering does anyone know if Indy automatically
handle gzip, deflate?

Yes it does, if you assign a Compressor component to the TIdHTTP.Compressor
property, such as TIdCompressorZLib, eg:

shared_ptr<TIdHTTP> request( new TIdHTTP( NULL ) );
 
shared_ptr<TIdCompressorZLib> compress( new TIdCompressorZLib( NULL ) );
request->Compressor = compress.get();
 
request->Request->Accept =    "*/*";
request->Request->AcceptEncoding =    "gzip, deflate";
 
String response = request->Get( L"http://mywebserver" );


request->Request->AcceptEncoding = "gzip, deflate";

Do not assign that property manually, unless you download the response data
to a TStream instead of a String and are prepared to decompress the TStream
data manually after TIdHTTP.Get() exits. Otherwise, let TIdHTTP manage that
property for you, based on the capabilities of the assigned Compressor.

Will "response" be the uncompressed, deflated content?

If a Compressor component is assigned, yes.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02