deflate

What's the most that GZIP or DEFLATE can increase a file size?

拥有回忆 提交于 2019-12-05 04:31:00
It's well known that GZIP or DEFLATE (or any compression mechanism) can increase file size sometimes. Is there a maximum (either percentage or constant) that a file can be increased? What is it? If a file is X bytes, and I'm going to gzip it, and I need to budget for file space in advance - what's the worst case scenario? UPDATE: There are two overheads: GZIP adds a header, typically 18 bytes but essentially arbitrarily long. What about DEFLATE? That can expand content by a multiplicative factor, which I don't know. Does anyone know what it is? gzip will add a header and trailer of at least 18

C# decode (decompress) Deflate data of PDF File

 ̄綄美尐妖づ 提交于 2019-12-05 03:46:59
问题 I would like to decompress in C# some DeflateCoded data (PDF extracted). Unfortunately I got every time the exception "Found invalid data while decoding.". But the data are valid. private void Decompress() { FileStream fs = new FileStream(@"S:\Temp\myFile.bin", FileMode.Open); //First two bytes are irrelevant fs.ReadByte(); fs.ReadByte(); DeflateStream d_Stream = new DeflateStream(fs, CompressionMode.Decompress); StreamToFile(d_Stream, @"S:\Temp\myFile1.txt", FileMode.OpenOrCreate); d_Stream

DeflateStream doesnt work on MemoryStream?

你离开我真会死。 提交于 2019-12-05 01:19:02
I have the following piece of code: MemoryStream resultStream = new MemoryStream(); string users = ""//Really long string goes here BinaryFormatter bFormatter = new BinaryFormatter(); using (MemoryStream assignedUsersStream = new MemoryStream()) { bFormatter.Serialize(assignedUsersStream, users); assignedUsersStream.Position = 0; using (var compressionStream = new DeflateStream(resultStream, CompressionLevel.Optimal)) { assignedUsersStream.CopyTo(compressionStream); Console.WriteLine("Compressed from {0} to {1} bytes.", assignedUsersStream.Length.ToString(), resultStream.Length.ToString()); }

HttpWebRequest gets slower when adding an Interval

删除回忆录丶 提交于 2019-12-04 20:11:52
Testing different possibilities to download the source of a webpage I got the following results (Average time in ms to google.com, 9gag.com): Plain HttpWebRequest: 169, 360 Gzip HttpWebRequest: 143, 260 WebClient GetStream : 132 , 295 WebClient DownloadString: 143, 389 So for my 9gag client I decided to take the gzip HttpWebRequest. The problem is, after implementing in my actual program, the request takes more than twice the time. The Problem also occurs when just adding a Thread.Sleep between two requests. EDIT: Just improved the code a bit, still the same problem: When running in a loop the

Enabling compression on Heroku using python

久未见 提交于 2019-12-04 17:41:56
问题 Google now penalizes due to not being so mobile friendly. So in an effort to make things better, it recommends I compress a lot of my Javascript with Gzip or Deflate. I've seen some old recommendations on stack overflow, but there is nothing out of the box and I tried searching for add-ons, but as yet there doesn't appear to be anything that would do the trick. What is the least painful and robust of compressing or enabling gzip? Here is what Google suggests I do: Enable compression

AngularJS - How to deflate and encode/decode to base64 all jsons request?

巧了我就是萌 提交于 2019-12-04 03:47:19
Lets say i have several $resources and some $http around my angular application: myApp.factory('Note', function($resource) { return $resource('http://', {id: '@id'}, { 'index': { method: 'GET', isArray: true }, 'update': { method: 'PUT'}, }); }); with controller myApp.controller('NotesController',function NotesController($scope, Note, AuthenticationService) { $scope.notes = Note.index({}, function(data){ console.log('success, got data: ', data); $scope.response = "yoy!" }, function(err){ console.log('error, got data: ', err); $scope.response = "yay!" }); }); and some request are made by $http

deflate and inflate (zlib.h) in C

只愿长相守 提交于 2019-12-03 19:07:05
问题 I am trying to implement the zlib.h deflate and inflate functions to compress and decompress a char array (not a file). I would like to know if the following syntax is correct ? Am I missing something or defined something incorrectly ? char a[50] = "Hello World!"; char b[50]; char c[50]; // deflate // zlib struct z_stream defstream; defstream.zalloc = Z_NULL; defstream.zfree = Z_NULL; defstream.opaque = Z_NULL; defstream.avail_in = (uInt)sizeof(a); // size of input defstream.next_in = (Bytef

ServiceStack - Using gzip/deflate compression with JSONP requests

廉价感情. 提交于 2019-12-03 13:27:27
I have a ServiceStack service that compresses the response using RequestContext.ToOptimizedResult() , e.g.: [Route("/numbers/search")] public class FindNumbers { } public object Get(FindNumbers query) { var data = new List<string> { "One", "Two", "Three" }; return RequestContext.ToOptimizedResult(data); } This works perfectly when issuing a request like: GET http://myhost:13487/numbers/search.json And is compressed as expected with the Accept-Encoding request header: Accept-Encoding: gzip,deflate,sdch I can also issue a JSONP request: GET http://myhost:13487/numbers/search?callback=func which

Enabling compression on Heroku using python

怎甘沉沦 提交于 2019-12-03 11:25:00
Google now penalizes due to not being so mobile friendly. So in an effort to make things better, it recommends I compress a lot of my Javascript with Gzip or Deflate. I've seen some old recommendations on stack overflow, but there is nothing out of the box and I tried searching for add-ons, but as yet there doesn't appear to be anything that would do the trick. What is the least painful and robust of compressing or enabling gzip? Here is what Google suggests I do: Enable compression Compressing resources with gzip or deflate can reduce the number of bytes sent over the network. Enable

Deflate Compression Stream where pre compressed Data can be inserted. Does a .NET lib exist?

試著忘記壹切 提交于 2019-12-01 11:13:33
I'm implementing Deflate and GZip compression for web content. The .NET Framework DeflateStream performs very well (it doesn't compress that good as SharpZipLib, but it is much faster). Unfortunately it (and all other libs i know) miss a function to write precompressed data like stream.WritePrecompressed(byte[] buffer). With this function it would be possible to insert precompressed blocks in the stream. This could reduce the cpu load for compressing this part and increase the total throughput of the web server. Is there any managed lib capable of doing this? Or is there any good starting