Comparing version 8.1.1 to 8.2.0
import Promise = require('any-promise'); | ||
import Base, { BaseOptions, Headers } from './base'; | ||
import Response from './response'; | ||
import Response, { ResponseJSON } from './response'; | ||
import PopsicleError from './error'; | ||
@@ -23,2 +23,3 @@ export interface DefaultsOptions extends BaseOptions { | ||
method: string; | ||
response: ResponseJSON; | ||
} | ||
@@ -37,2 +38,3 @@ export interface TransportOptions { | ||
transport: TransportOptions; | ||
response: Response; | ||
middleware: Middleware[]; | ||
@@ -39,0 +41,0 @@ opened: boolean; |
@@ -23,6 +23,2 @@ "use strict"; | ||
this.downloaded = 0; | ||
this.uploadedBytes = null; | ||
this.downloadedBytes = null; | ||
this.uploadLength = null; | ||
this.downloadLength = null; | ||
this._progress = []; | ||
@@ -32,6 +28,9 @@ this.timeout = (options.timeout | 0); | ||
this.body = options.body; | ||
var promised = new Promise(function (resolve, reject) { | ||
var $promise = new Promise(function (resolve, reject) { | ||
_this._resolve = resolve; | ||
_this._reject = reject; | ||
}); | ||
this.transport = extend(options.transport); | ||
this.use(options.use || this.transport.use); | ||
this.progress(options.progress); | ||
this._promise = Promise.resolve() | ||
@@ -42,9 +41,6 @@ .then(function () { | ||
_this._handle(); | ||
return promised; | ||
return $promise; | ||
}; | ||
return run(_this, cb); | ||
}); | ||
this.transport = extend(options.transport); | ||
this.use(options.use || this.transport.use); | ||
this.progress(options.progress); | ||
} | ||
@@ -80,6 +76,7 @@ Request.prototype.error = function (message, code, original) { | ||
url: this.url, | ||
method: this.method, | ||
headers: this.headers, | ||
body: this.body, | ||
timeout: this.timeout, | ||
method: this.method | ||
response: this.response ? this.response.toJSON() : null | ||
}; | ||
@@ -150,3 +147,6 @@ }; | ||
return this.transport.open(this) | ||
.then(function (res) { return _this._resolve(res); }, function (err) { return _this._reject(err); }); | ||
.then(function (response) { | ||
_this.response = response; | ||
_this._resolve(response); | ||
}, function (err) { return _this._reject(err); }); | ||
}; | ||
@@ -153,0 +153,0 @@ Object.defineProperty(Request.prototype, "completed", { |
@@ -1,2 +0,2 @@ | ||
import Base, { BaseOptions, Headers, RawHeaders } from './base'; | ||
import Base, { BaseOptions, Headers } from './base'; | ||
export interface ResponseOptions extends BaseOptions { | ||
@@ -9,3 +9,2 @@ body: any; | ||
headers: Headers; | ||
rawHeaders: RawHeaders; | ||
body: any; | ||
@@ -12,0 +11,0 @@ url: string; |
@@ -23,3 +23,2 @@ "use strict"; | ||
headers: this.headers, | ||
rawHeaders: this.rawHeaders, | ||
body: this.body, | ||
@@ -26,0 +25,0 @@ status: this.status, |
@@ -55,6 +55,7 @@ "use strict"; | ||
var req = popsicle.get(REMOTE_URL + '/echo'); | ||
t.plan(13); | ||
t.plan(14); | ||
return req | ||
.then(function (res) { | ||
t.ok(res instanceof popsicle.Response); | ||
t.equal(req.response, res); | ||
t.ok(typeof res.url === 'string' || res.url == null); | ||
@@ -69,4 +70,4 @@ t.ok(Array.isArray(res.rawHeaders)); | ||
t.equal(typeof res.toJSON, 'function'); | ||
t.deepEqual(Object.keys(req.toJSON()), ['url', 'headers', 'body', 'timeout', 'method']); | ||
t.deepEqual(Object.keys(res.toJSON()), ['url', 'headers', 'rawHeaders', 'body', 'status', 'statusText']); | ||
t.deepEqual(Object.keys(req.toJSON()), ['url', 'method', 'headers', 'body', 'timeout', 'response']); | ||
t.deepEqual(Object.keys(res.toJSON()), ['url', 'headers', 'body', 'status', 'statusText']); | ||
return req | ||
@@ -73,0 +74,0 @@ .then(function (res2) { |
{ | ||
"name": "popsicle", | ||
"version": "8.1.1", | ||
"version": "8.2.0", | ||
"description": "Simple HTTP requests for node and the browser", | ||
@@ -56,3 +56,3 @@ "main": "dist/common.js", | ||
"devDependencies": { | ||
"blue-tape": "^0.2.0", | ||
"blue-tape": "^1.0.0", | ||
"bluebird": "^3.0.5", | ||
@@ -74,3 +74,3 @@ "body-parser": "^1.9.2", | ||
"concat-stream": "^1.4.7", | ||
"form-data": "^1.0.1", | ||
"form-data": "^2.0.0", | ||
"make-error-cause": "^1.2.1", | ||
@@ -77,0 +77,0 @@ "throwback": "^1.1.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
233543
2116
+ Addedasynckit@0.4.0(transitive)
+ Addedform-data@2.5.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
- Removedasync@2.6.4(transitive)
- Removedform-data@1.0.1(transitive)
- Removedlodash@4.17.21(transitive)
Updatedform-data@^2.0.0