Does Apache Commons HttpClient support GZIP?
Apache HttpClient 4.1 supports content compression out of the box along with many other features that were previously considered out of scope.
Apache HttpClient 4.1 supports content compression out of the box along with many other features that were previously considered out of scope.
To extract files from a .tar.gz file you can use the following methods from packages distributed with Ruby: require ‘rubygems/package’ require ‘zlib’ tar_extract = Gem::Package::TarReader.new(Zlib::GzipReader.open(‘Path/To/myfile.tar.gz’)) tar_extract.rewind # The extract has to be rewinded after every iteration tar_extract.each do |entry| puts entry.full_name puts entry.directory? puts entry.file? # puts entry.read end tar_extract.close Each entry of type Gem::Package::TarReader::Entry … Read more
Preface .NET [4 and previous] users should not use the Microsoft-provided GZipStream or DeflateStream classes under any circumstances, unless Microsoft replaces them completely with something that works. Use the DotNetZip library instead. Update to Preface The .NET Framework 4.5 and later have fixed the compression problem, and GZipStream and DeflateStream use zlib in those versions. … Read more
The issue with the gzip module is not that it can’t decompress the partial file, the error occurs only at the end when it tries to verify the checksum of the decompressed content. (The original checksum is stored at the end of the compressed file so the verification will never, ever work with a partial … Read more
Uncompressed size is stored in the last 4 bytes of the gzip file. We can read the binary data and convert it to an int. (This will only work for files under 4GB) import struct def getuncompressedsize(filename): with open(filename, ‘rb’) as f: f.seek(-4, 2) return struct.unpack(‘I’, f.read(4))[0]
Thanks for your WCF tip! We’re going to be enabling IIS compression for services at my shop, and I’m hoping your solution will work. By “To make this work for Web Services” – did you mean old school SoapHttpProtocol clients? Because the SoapHttpProtocol class has a built-in EnableDecompression property, which will automatically handle the Compression … Read more
GZip Compression can be enabled directly through IIS. First, open up IIS, go to the website you are hoping to tweak and hit the Compression page. If Gzip is not installed, you will see something like the following: “The dynamic content compression module is not installed.” We should fix this. So we go to the … Read more
I’ve written a wrapper for commons-compress called jarchivelib that makes it easy to extract or compress from and into File objects. Example code would look like this: File archive = new File(“/home/thrau/archive.tar.gz”); File destination = new File(“/home/thrau/archive/”); Archiver archiver = ArchiverFactory.createArchiver(“tar”, “gz”); archiver.extract(archive, destination);
This code does the trick // Name of the file we’re compressing $file = “test.txt”; // Name of the gz file we’re creating $gzfile = “test.gz”; // Open the gz file (w9 is the highest compression) $fp = gzopen ($gzfile, ‘w9’); // Compress the file gzwrite ($fp, file_get_contents($file)); // Close the gz file and we’re … Read more