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 data gets corrupted in IE8 or below var skipVerification = (browserName === 'IE' && browserVersion <= 8) var reference = fs.readFileSync(__dirname + '/../server/static/browserify.png') test('binary download', function (t) { http.get('/browserify.png', function (res) { var buffers = [] res.on('end', function () { if (skipVerification) t.skip('binary data not preserved on IE <= 8') else t.ok(reference.equals(Buffer.concat(buffers)), 'contents match') t.end() }) res.on('data', function (data) { buffers.push(data) }) }) })
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/stream-http/test/browser/binary.js | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |