1 // test compression/decompression with dictionary
3 var common = require('../common.js');
4 var assert = require('assert');
5 var zlib = require('zlib');
6 var path = require('path');
8 var spdyDict = new Buffer([
9 'optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-',
10 'languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi',
11 'f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser',
12 '-agent10010120020120220320420520630030130230330430530630740040140240340440',
13 '5406407408409410411412413414415416417500501502503504505accept-rangesageeta',
14 'glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic',
15 'ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran',
16 'sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati',
17 'oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo',
18 'ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe',
19 'pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic',
20 'ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1',
21 '.1statusversionurl\0'
24 var deflate = zlib.createDeflate({ dictionary: spdyDict });
36 // We'll use clean-new inflate stream each time
37 // and .reset() old dirty deflate one
40 var inflate = zlib.createInflate({ dictionary: spdyDict });
44 deflate.removeAllListeners('data');
47 // Put data into deflate stream
48 deflate.on('data', function(chunk) {
52 // Get data from inflate stream
54 inflate.on('data', function(chunk) {
57 inflate.on('end', function() {
60 assert.equal(output.join(''), input);
62 if (num < 2) run(num + 1);
66 deflate.flush(function() {
72 process.on('exit', function() {
73 assert.equal(called, 2);