Socket
Socket
Sign inDemoInstall

http-browserify

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-browserify - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0

1

example/post/main.js

@@ -0,1 +1,2 @@

alert('what is this');
var http = require('../../');

@@ -2,0 +3,0 @@

var Stream = require('stream');
var Response = require('./response');
var concatStream = require('concat-stream');
var Base64 = require('Base64');
var util = require('util');
var inherits = require('inherits');

@@ -11,3 +10,3 @@ var Request = module.exports = function (xhr, params) {

self.xhr = xhr;
self.body = concatStream()
self.body = [];

@@ -62,3 +61,3 @@ self.uri = (params.scheme || 'http') + '://'

util.inherits(Request, Stream);
inherits(Request, Stream);

@@ -77,3 +76,3 @@ Request.prototype.setHeader = function (key, value) {

Request.prototype.write = function (s) {
this.body.write(s);
this.body.push(s);
};

@@ -87,5 +86,39 @@

Request.prototype.end = function (s) {
if (s !== undefined) this.body.write(s);
this.body.end()
this.xhr.send(this.body.getBody());
if (s !== undefined) this.body.push(s);
if (this.body.length === 0) {
this.xhr.send('');
}
else if (typeof this.body[0] === 'string') {
this.xhr.send(this.body.join(''));
}
else if (isArray(this.body[0])) {
var body = [];
for (var i = 0; i < this.body.length; i++) {
body.push.apply(body, this.body[i]);
}
this.xhr.send(body);
}
else if (/Array/.test(Object.prototype.toString.call(this.body[0]))) {
var len = 0;
for (var i = 0; i < this.body.length; i++) {
len += this.body[i].length;
}
var body = new(this.body[0].constructor)(len);
var k = 0;
for (var i = 0; i < this.body.length; i++) {
var b = this.body[i];
for (var j = 0; j < b.length; j++) {
body[k++] = b[j];
}
}
this.xhr.send(body);
}
else {
var body = '';
for (var i = 0; i < this.body.length; i++) {
body += this.body[i].toString();
}
this.xhr.send(body);
}
};

@@ -92,0 +125,0 @@

6

package.json
{
"name": "http-browserify",
"version": "0.3.0",
"version": "1.0.0",
"description": "http module compatability for browserify",

@@ -13,4 +13,4 @@ "main": "index.js",

"dependencies": {
"concat-stream": "~1.0.0",
"Base64": "~0.1.2"
"Base64": "~0.1.2",
"inherits": "~2.0.1"
},

@@ -17,0 +17,0 @@ "devDependencies": {

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