http-browserify
Advanced tools
Comparing version 0.3.0 to 1.0.0
@@ -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 @@ |
{ | ||
"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": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6689
1
616564
53
+ Addedinherits@~2.0.1
+ Addedinherits@2.0.4(transitive)
- Removedconcat-stream@~1.0.0
- Removedbase64-js@0.0.2(transitive)
- Removedbops@0.0.6(transitive)
- Removedconcat-stream@1.0.1(transitive)
- Removedto-utf8@0.0.1(transitive)