Sha256: 84722dbe58bb6fe73f529dd664286c535bfbd54827efde81e2770279f6ed4a50

Contents?: true

Size: 1.14 KB

Versions: 35

Compression:

Stored size: 1.14 KB

Contents

var Buffer = require('buffer').Buffer
var fs = require('fs')
var test = require('tape')
var UAParser = require('ua-parser-js')

var http = require('../..')

var browser = (new UAParser()).setUA(navigator.userAgent).getBrowser()
var browserName = browser.name
var browserVersion = browser.major
// Streaming doesn't work in IE9 or below
var skipStreamingCheck = (browserName === 'IE' && browserVersion <= 9)

var COPIES = 1000
var MIN_PIECES = 5

var referenceOnce = fs.readFileSync(__dirname + '/../server/static/basic.txt')
var reference = new Buffer(referenceOnce.length * COPIES)
for(var i = 0; i < COPIES; i++) {
	referenceOnce.copy(reference, referenceOnce.length * i)
}

test('text streaming', function (t) {
	http.get({
		path: '/basic.txt?copies=' + COPIES,
		mode: 'prefer-streaming'
	}, function (res) {
		var buffers = []

		res.on('end', function () {
			if (skipStreamingCheck)
				t.skip('streaming not available on IE <= 8')
			else
				t.ok(buffers.length >= MIN_PIECES, 'received in multiple parts')
			t.ok(reference.equals(Buffer.concat(buffers)), 'contents match')
			t.end()
		})

		res.on('data', function (data) {
			buffers.push(data)
		})
	})
})

Version data entries

35 entries across 34 versions & 12 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/stream-http/test/browser/text-streaming.js
disco_app-0.18.0 test/dummy/node_modules/stream-http/test/browser/text-streaming.js
disco_app-0.18.2 test/dummy/node_modules/stream-http/test/browser/text-streaming.js
disco_app-0.16.1 test/dummy/node_modules/stream-http/test/browser/text-streaming.js
disco_app-0.15.2 test/dummy/node_modules/stream-http/test/browser/text-streaming.js
disco_app-0.18.4 test/dummy/node_modules/stream-http/test/browser/text-streaming.js
disco_app-0.18.1 test/dummy/node_modules/stream-http/test/browser/text-streaming.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/stream-http/test/browser/text-streaming.js
disco_app-0.14.0 test/dummy/node_modules/stream-http/test/browser/text-streaming.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/stream-http/test/browser/text-streaming.js
tang-0.2.1 spec/tang_app/node_modules/stream-http/test/browser/text-streaming.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/stream-http/test/browser/text-streaming.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/stream-http/test/browser/text-streaming.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/stream-http/test/browser/text-streaming.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/stream-http/test/browser/text-streaming.js
tang-0.2.0 spec/tang_app/node_modules/stream-http/test/browser/text-streaming.js
tang-0.1.0 spec/tang_app/node_modules/stream-http/test/browser/text-streaming.js
tang-0.0.9 spec/tang_app/node_modules/stream-http/test/browser/text-streaming.js
enju_library-0.3.8 spec/dummy/node_modules/stream-http/test/browser/text-streaming.js
ilog-0.4.1 node_modules/stream-http/test/browser/text-streaming.js