Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

requests

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

requests - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

.min-wd

7

browser.js

@@ -72,2 +72,3 @@ 'use strict';

var what
, slice = true
, requests = this

@@ -77,3 +78,5 @@ , socket = requests.socket;

requests.on('stream', function stream(data) {
if (socket.multipart) return requests.emit('data', data);
if (!slice) {
return requests.emit('data', data);
}

@@ -130,4 +133,6 @@ //

socket.multipart = true;
slice = false;
} else if (Requests.type.mozchunkedtext) {
socket.responseType = 'moz-chunked-text';
slice = false;
}

@@ -134,0 +139,0 @@ } else {

9

package.json
{
"name": "requests",
"version": "0.1.5",
"description": "An XHR abstraction that works in browsers and node.js",
"version": "0.1.6",
"description": "An streaming XHR abstraction that works in browsers and node.js",
"main": "index.js",

@@ -9,2 +9,3 @@ "browser": "browser.js",

"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"wd": "node test/index.js --wd",
"test": "node test/index.js",

@@ -51,6 +52,8 @@ "static": "node test/static.js",

"browserify": "8.x.x",
"http-proxy": "1.11.x",
"istanbul": "0.3.x",
"mocha": "2.2.x",
"mochify": "2.7.x",
"pre-commit": "1.0.x"
"pre-commit": "1.0.x",
"setheader": "0.0.x"
},

@@ -57,0 +60,0 @@ "testling": {

'use strict';
var Mocha = require('mocha')
, mochify = require('mochify');
, mochify = require('mochify')
, wd = process.argv[2] === '--wd';

@@ -60,4 +61,5 @@ /**

reporter: 'spec',
cover: true,
ui: 'bdd'
cover: !wd,
ui: 'bdd',
wd: wd
})

@@ -64,0 +66,0 @@ .bundle(next);

@@ -10,3 +10,4 @@ describe('requests', function () {

var requests = require('../browser')
var Requested = require('../requested')
, requests = require('../browser')
, assume = require('assume')

@@ -16,3 +17,3 @@ , req;

beforeEach(function () {
req = requests('http://localhost:8080', { manual: true });
req = requests(unique('http://localhost:8080'), { manual: true });
});

@@ -24,2 +25,13 @@

/**
* Make a URL unique so we can bust the browser cache which could affect
*
* @param {String} url Transform to an URL.
* @returns {String}
* @api private
*/
function unique(url) {
return url + '?t='+ (+ new Date());
}
it('is exported as function', function () {

@@ -32,9 +44,9 @@ assume(requests).is.a('function');

assume(id).equals(requests.requested);
assume(id).equals(Requested.requested);
req.destroy();
req = requests('http://localhost:8080', { manual: true });
req = requests(unique('http://localhost:8080'), { manual: true });
assume(req.id).is.above(id);
assume(requests.requested).is.above(id);
assume(Requested.requested).is.above(id);
});

@@ -51,2 +63,28 @@

it('can handle large files with streaming', function (done) {
this.timeout(3E4);
req = requests(unique('http://localhost:8080/unshiftio/requests/master/test/large.js'), {
streaming: true
});
var buffer = [];
req.on('data', function received(chunk) {
buffer.push(chunk);
});
req.on('error', done);
req.once('end', function end(err, status) {
assume(buffer.length).to.be.above(1);
assume(buffer.join('').length).equals(2127897);
assume(status.code).to.equal(200);
assume(status.text).to.equal('OK');
buffer = null;
done();
});
});
describe('#destroy', function () {

@@ -53,0 +91,0 @@ it('removes the .active instance', function () {

@@ -6,14 +6,19 @@ 'use strict';

, path = require('path')
, http = require('http');
, http = require('http')
, setHeader = require('setheader')
, httpProxy = require('http-proxy');
module.exports = function staticserver(kill, next) {
var proxy = httpProxy.createProxyServer({});
var server = http.createServer(function serve(req, res) {
var file = path.join(__dirname, url.parse(req.url).pathname);
res.setHeader('Access-Control-Allow-Origin', req.headers.origin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
setHeader(res, 'Access-Control-Allow-Origin', req.headers.origin || '*');
setHeader(res, 'Access-Control-Allow-Credentials', 'true');
if (!fs.existsSync(file)) {
res.statusCode = 404;
return res.end('nope');
req.headers.host = '';
setHeader(res, 'Content-Security-Policy', 'removed');
return proxy.web(req, res, { target: 'https://raw.githubusercontent.com' });
}

@@ -27,2 +32,3 @@

server.close(next);
proxy.close();
});

@@ -29,0 +35,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc