deflate

Are zlib.compress on Python and Deflater.deflate on Java (Android) compatible?

时光毁灭记忆、已成空白 提交于 2019-11-28 08:03:52
问题 I am porting a Python application to Android and, at some point, this application has to communicate with a Web Service, sending it compressed data. In order to do that it uses the next method: def stuff(self, data): "Convert into UTF-8 and compress." return zlib.compress(simplejson.dumps(data)) I am using the next method to try to emulate this behavior in Android: private String compressString(String stringToCompress) { Log.i(TAG, "Compressing String " + stringToCompress); byte[] input =

php - Get compressed contents using cURL

回眸只為那壹抹淺笑 提交于 2019-11-28 05:10:59
问题 I need to get content of various web pages. Some of them are compressed using different methods (gzip, deflate, etc). I've searched on the Internet and found the solution for gzipped content: $ch = curl_init("http://games2k.net/"); curl_setopt($ch,CURLOPT_ENCODING , "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); echo $output; However, this only works for a single method. I need a solution that works for as many compression methods as possible

Why do real-world servers prefer gzip over deflate encoding?

佐手、 提交于 2019-11-28 03:26:41
We already know deflate encoding is a winner over gzip with respect to speed of encoding, decoding and compression size. So why do no large sites (that I can find) send it (when I use a browser that accepts it)? Yahoo claims deflate is "less effective". Why? I maintain HTTP server software that prefers deflate, so I'd like to know if there's some really good reason not to continue doing so. There is some confusion about the naming between the specifications and the HTTP: DEFLATE as defined by RFC 1951 is a compressed data format . ZLIB as defined by RFC 1950 is a compressed data format that

Is it possible to force jQuery to make AJAX calls for URLs with gzip/deflate enabled?

对着背影说爱祢 提交于 2019-11-27 20:32:15
I have a web service that is willing to output gzip/deflated data. I've verified that the service will respond with raw JSON or with gzip'd JSON using wget and curl. I want to consume this web service using the jQuery AJAX call. By default, the $.ajax call that jQuery provides does not add the "Accept-Encoding: gzip" HTTP request header that's necessary for the web server to respond with gzipped data. However, when I use jQuery's own methods to add the header, eg: $.ajax({url: 'http://foo.com/service.json', beforeSend: function(xhr) { console.log('xhr set'); xhr.setRequestHeader('Accept

Using Java Deflater/Inflater with custom dictionary causes IllegalArgumentException

爱⌒轻易说出口 提交于 2019-11-27 16:43:59
问题 The following code is based on the example given in the javadocs for java.util.zip.Deflater. The only changes I have made is to create a byte array called dict and then set the dictionary on both the Deflater and Inflater instances using the setDictionary(byte[]) method. The problem I'm seeing is that when I call Inflater.setDictionary() with the exact same array as I used for the Deflater, I get an IllegalArgumentException. Here is the code in question: import java.util.zip.Deflater; import

apache compression Deflate .js and .css files not compressed?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 11:15:20
问题 In Apache Im enabling output compression by adding the following to my .htaccess file: # compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript

Compress/Decompress NSString in objective-c (iphone) using GZIP or deflate

泪湿孤枕 提交于 2019-11-27 09:17:30
I have a web-service running on Windows Azure which returns JSON that I consume in my iPhone app. Unfortunately, Windows Azure doesn't seem to support the compression of dynamic responses yet (long story) so I decided to get around it by returning an uncompressed JSON package, which contains a compressed (using GZIP) string. e.g {"Error":null,"IsCompressed":true,"Success":true,"Value":"vWsAAB+LCAAAAAAAB..etc.."} ... where value is the compressed string of a complex object represented in JSON. This was really easy to implement on the server, but for the life of me I can't figure out how to

JavaScript DEFLATE Implementation [closed]

僤鯓⒐⒋嵵緔 提交于 2019-11-27 01:48:46
问题 Are there any open source DEFLATE encoder implementations for JavaScript? I need it to generate a binary format on the client-side that requires DEFLATE. 回答1: I believe Pako (https://github.com/nodeca/pako) is now the fastest javascript implementation of deflate and other zlib methods (inflate / gzip / ungzip). There are benchmarks on the github page. It also supports chunking if you need to work with big blobs. Disclaimer: I am the author of this code. 回答2: I found a DEFLATE encoder and

Zlib compression Using Deflate and Inflate classes in Java

一世执手 提交于 2019-11-27 01:23:48
问题 I want trying to use the Deflate and Inflate classes in java.util.zip for zlib compression. I am able to compress the code using Deflate, but while decompressing, I am having this error - Exception in thread "main" java.util.zip.DataFormatException: unknown compression method at java.util.zip.Inflater.inflateBytes(Native Method) at java.util.zip.Inflater.inflate(Inflater.java:238) at java.util.zip.Inflater.inflate(Inflater.java:256) at zlibCompression.main(zlibCompression.java:53) Here is my

How to find a good/optimal dictionary for zlib 'setDictionary' when processing a given set of data?

只愿长相守 提交于 2019-11-27 00:45:26
问题 I have a (huge) set of similar data files. The set is constantly growing. The size of a single file is about 10K. Each file must be compressed on its own. The compression is done with the zlib library, which is used by the java.util.zip.Deflater class. When passing a dictionary to the Deflate algorithm using setDictionary , I can improve the compression ratio. Is there a way (algorithm) to find the 'optimal' dictionary, i.e. a dictionary with the overall optimal compression ratio? See zlib