Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

How can I decompress the gzip file???

When I receive some content from the TClientSocket Component. The header is:

HTTP/1.1 200 OK
Date: Thu, 27 Mar 2003 16:03:15 GMT
Server: Apache/1.3.22 (Unix) mod_gzip/1.3.19.1a mod_cache/1.0.0
mod_baidu/4.1.1
Status: 0
Connection: close
Content-Type: text/html
Content-Encoding: gzip
Content-Length: 5428


How can I read the zip content of "Content-Encoding: gzip" in Delphi5???

HELP!!!
0
honestman
Asked:
honestman
1 Solution
 
SpetsonCommented:
humm...
What component type are you using to make the connection to the Host?
What type of allowed content/type you specified for this component?
Can you post some more details about your project?
0
 
Spida_81Commented:
I am working on that, too.
I am using Delphi-zlib from
http://www.gewis.win.tue.nl/info/delphizlib/delphizlib.zip

I had to patch it a bit, seems to be made for some earlier version of delphi.
Mostly you'll have to remove every mention of
RegisterPropertyEditor and DsgnIntf in some uses-clauses has become DesignIntf

================================================

uses ..., classes, gzio;

procedure read(FileName:String)
var File:TMemoryStream;
    Input:TStringStream;
    zippedfile:gzfile;
begin
   File := TMemoryStream.Create();
   Input := TStringStream.Create('');

   File.LoadFromFile(FileName);
   zippedfile:=gzopen(FileName,'r',0);
   gzread (zippedfile, File.Memory, File.Size);
   gzclose(zippedfile);
   Input.CopyFrom(File, LFile.Size);

   //Here you have your file in the Stringstream Input

   File.free;
   Input.free;
end;
0
 
mocartsCommented:
...and RegisterPropertyEditor has moved to DesignEditors :)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Spida_81Commented:
I am working with this, too.

Currently I am using DelphiZlib
http://www.gewis.win.tue.nl/info/delphizlib/delphizlib.zip

You'll have to patch it a bit, it seems to be written for an earlier version of Delphi.
You'll have to delete every occurence of "RegisterPropertyEditor"
and change "DsgnIntf" to "DesignIntf" in every uses-clause.

You can the use it with:

uses classes, gzio;

Procedure Readfile(FileName:String);
var File:TMemoryStream;
    Input:TStringStream;
    zippedfile:gzfile;
begin
   File := TMemoryStream.Create();
   Input := TStringStream.Create('');
   File.LoadFromFile(FileName);
   zippedfile:=gzopen(OpenDialog.FileName,'r',0);
   gzread (zippedfile, File.Memory, File.Size);
   gzclose(zippedfile);
   Input.CopyFrom(File, File.Size);
   
   //here you have your files in the Memorystream "File" or in Stringstream Input
   
   File.free;
   Input.free;
end;
0
 
Spida_81Commented:
sorry for repost, it did come up on my cached version of the page
0
 
honestmanAuthor Commented:
Test is passed.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now