Sha256: 7b622ad50ea6eab354d0e6a4ca003bfb3c49418250f6b36c34ba8f120a0cfb63

Contents?: true

Size: 1.12 KB

Versions: 35

Compression:

Stored size: 1.12 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
// Binary request bodies don't work in a bunch of browsers
var skipVerification = ((browserName === 'IE' && browserVersion <= 10) ||
	(browserName === 'Safari' && browserVersion <= 5) ||
	(browserName === 'WebKit' && browserVersion <= 534) || // Old mobile safari
	(browserName === 'Android Browser' && browserVersion <= 4))

var reference = fs.readFileSync(__dirname + '/../server/static/browserify.png')

test('post binary', function (t) {
	var req = http.request({
		path: '/echo',
		method: 'POST'
	}, function (res) {
		var buffers = []

		res.on('end', function () {
			if (skipVerification)
				t.skip('binary data not preserved on this browser')
			else
				t.ok(reference.equals(Buffer.concat(buffers)), 'echoed contents match')
			t.end()
		})

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

	req.write(reference)
	req.end()
})

Version data entries

35 entries across 34 versions & 12 rubygems

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