Thoughts from Dan Miser RSS 2.0
# Thursday, January 19, 2006
If you want to retrieve content from a web server that supports gzip compression, you have a few ways to get data from this web server, of which, here are a couple:

  1. Use TIdHttp and assign IdHttp1.Request.AcceptEncoding to blank. If you do this, a Get call to the web server will return the full text and you will not see the benefits of the gzip compression that can occur on the web server. Not exactly what we want.
  2. Use TIdHttp and assign IdHttp1.Request.AcceptEncoding to 'gzip'. If you do this, the web server will return gzipped content when doing an IdHttp1.Get(URL) call.

If you use #2 above, you will need to manually decode the returned data. I found the LVK components from the LVK web site to be most helpful in this task. I couldn't easily get the standard zlib or Indy10 zlib implementation to work with gzip encoding, so I ended up using LVK. Using the code below, you get the data back in compressed format and decode it. As an aside, it looks like LVK also supports the deflate option in addition to the gzip option, and has TONS of components and utility code.


// add lvkZLibUtils to the uses clause
procedure TForm3.Button2Click(Sender: TObject);
var
  inStream, outStream: TMemoryStream;
begin
  inStream := TMemoryStream.Create;
  try
    IdHttp1.Get('http://www.pgatour.com', inStream);
    outStream := TMemoryStream.Create;
    try
      gZipDecompress(inStream, outStream);
      outStream.Position := 0;
      Memo1.Lines.LoadFromStream(outStream);
    finally
      outStream.Free;
    end;
  finally
    inStream.Free;
  end;
end;
Thursday, January 19, 2006 10:14:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -

Tracked by:
http://9nj-information.info/45066199/index.html [Pingback]
http://9nr-information.info/15474064/connecting-mac-book-to-wirless-router.html [Pingback]
http://9nm-information.info/40813181/index.html [Pingback]
http://9nm-information.info/14277338/index.html [Pingback]
http://9ne-information.info/83044741/index.html [Pingback]
http://9nn-information.info/12657468/index.html [Pingback]
http://9nq-information.info/64175960/index.html [Pingback]
http://9nn-information.info/59555846/motel-of-the-white-locust-audio.html [Pingback]
http://9nk-information.info/36191555/index.html [Pingback]
http://9no-information.info/42207015/index.html [Pingback]
http://9nk-information.info/89503147/index.html [Pingback]
http://9qk-information.info/78176814/gtr-forum.html [Pingback]
http://9ov-information.info/36419047/index.html [Pingback]
http://9qf-information.info/27880808/index.html [Pingback]
http://9on-information.info/85762250/health-impressions.html [Pingback]
http://9ob-information.info/41059081/index.html [Pingback]
http://9ov-information.info/44789103/index.html [Pingback]
http://9ql-information.info/85908536/index.html [Pingback]
http://9qq-information.info/68128386/index.html [Pingback]
http://9oe-information.info/37175607/index.html [Pingback]
http://9ry-information.info/30126702/spedding-ticket-fine-valdosta.html [Pingback]
http://9rx-information.info/09303307/wood-book-case-white.html [Pingback]
http://9st-information.info/87555475/index.html [Pingback]
http://9rl-information.info/12480329/index.html [Pingback]
http://9rv-information.info/12900764/index.html [Pingback]
http://9si-information.info/72707089/index.html [Pingback]
http://9sm-information.info/29457304/microsoft-flight-simulator-x-deluxe.html [Pingback]
http://9rf-information.info/72029249/index.html [Pingback]
http://9uafb-le-informazioni.info/77318953/index.html [Pingback]
http://9uaef-le-informazioni.info/72516299/index.html [Pingback]
http://9uafk-le-informazioni.info/62965574/kenwood-kdc-c467.html [Pingback]
http://9uaek-le-informazioni.info/34959594/index.html [Pingback]
http://9uaen-le-informazioni.info/31256417/hotel-maroma-cancun.html [Pingback]
http://9uaes-le-informazioni.info/68740589/index.html [Pingback]
http://9uaei-le-informazioni.info/53843284/index.html [Pingback]
http://9uaek-le-informazioni.info/56383682/index.html [Pingback]
http://9uafm-le-informazioni.info/04940968/valvola-venturi.html [Pingback]
http://9uaff-le-informazioni.info/72852930/offerta-lavoro-magazziniere-napoli.ht... [Pingback]
http://9uahr-le-informazioni.info/69326850/riparazione-barca-vetroresina-istruzi... [Pingback]
http://9uaht-le-informazioni.info/41388883/index.html [Pingback]
http://9uagi-le-informazioni.info/83304828/index.html [Pingback]
http://9uaha-le-informazioni.info/78650181/cagiva-planet.html [Pingback]
http://9uahs-le-informazioni.info/66448223/fuoristrada-4.html [Pingback]
http://9uaga-le-informazioni.info/03631908/index.html [Pingback]
Comments are closed.
Navigation
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Dan Miser
Sign In
Statistics
Total Posts: 375
This Year: 3
This Month: 0
This Week: 0
Comments: 654
Themes
Pick a theme:
All Content © 2012, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)