react / wstein / node_modules / browserify / node_modules / browserify-zlib / test / ignored / test-zlib-dictionary.js
80536 views// Copyright Joyent, Inc. and other Node contributors.1//2// Permission is hereby granted, free of charge, to any person obtaining a3// copy of this software and associated documentation files (the4// "Software"), to deal in the Software without restriction, including5// without limitation the rights to use, copy, modify, merge, publish,6// distribute, sublicense, and/or sell copies of the Software, and to permit7// persons to whom the Software is furnished to do so, subject to the8// following conditions:9//10// The above copyright notice and this permission notice shall be included11// in all copies or substantial portions of the Software.12//13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS14// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF15// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN16// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,17// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR18// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE19// USE OR OTHER DEALINGS IN THE SOFTWARE.2021// test compression/decompression with dictionary2223var common = require('../common.js');24var assert = require('assert');25var zlib = require('zlib');26var path = require('path');2728var spdyDict = new Buffer([29'optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-',30'languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi',31'f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser',32'-agent10010120020120220320420520630030130230330430530630740040140240340440',33'5406407408409410411412413414415416417500501502503504505accept-rangesageeta',34'glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic',35'ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran',36'sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati',37'oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo',38'ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe',39'pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic',40'ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1',41'.1statusversionurl\0'42].join(''));4344var deflate = zlib.createDeflate({ dictionary: spdyDict });4546var input = [47'HTTP/1.1 200 Ok',48'Server: node.js',49'Content-Length: 0',50''51].join('\r\n');5253var called = 0;5455//56// We'll use clean-new inflate stream each time57// and .reset() old dirty deflate one58//59function run(num) {60var inflate = zlib.createInflate({ dictionary: spdyDict });6162if (num === 2) {63deflate.reset();64deflate.removeAllListeners('data');65}6667// Put data into deflate stream68deflate.on('data', function(chunk) {69inflate.write(chunk);70});7172// Get data from inflate stream73var output = [];74inflate.on('data', function(chunk) {75output.push(chunk);76});77inflate.on('end', function() {78called++;7980assert.equal(output.join(''), input);8182if (num < 2) run(num + 1);83});8485deflate.write(input);86deflate.flush(function() {87inflate.end();88});89}90run(1);9192process.on('exit', function() {93assert.equal(called, 2);94});959697