Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions lib/docker-json-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ DockerJsonClient.prototype.write = function write(options, body, callback) {
return (this._super.write.call(this, options, resBody, callback));
};

DockerJsonClient.prototype.parse2 = function parse2(err, req, res, callback) {
if (!callback && req instanceof Function) {
callback = req;
req = undefined;
}

DockerJsonClient.prototype.parse = function parse(req, callback) {
function parseResponse(err, res) {
var chunks = []; // gunzipped response chunks (Buffer objects)
var len = 0; // accumulated count of chunk lengths
Expand Down Expand Up @@ -171,7 +175,6 @@ DockerJsonClient.prototype.parse = function parse(req, callback) {
callback(resErr, req, res, obj, body);
}


if (!res) {
// Early out if we didn't even get a response.
callback(resErr, req);
Expand Down Expand Up @@ -210,10 +213,24 @@ DockerJsonClient.prototype.parse = function parse(req, callback) {
});
}

return (parseResponse);
};
return parseResponse(err, res);

}

DockerJsonClient.prototype.parse = function parse(err, req, res, callback) {
if (!callback && req instanceof Function) {
callback = req;
req = undefined;
}

return this.parse2(err, req, res, function parse2Callback(resErr, req, res, obj, body) {
if (obj) {
callback(resErr, obj);
} else {
callback(resErr, res, obj, body);
}
});
}

// --- Exports

Expand Down
3 changes: 1 addition & 2 deletions lib/registry-client-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1602,8 +1602,7 @@ function _makeJsonRequest(opts, cb) {
return;
}
// Parse the response body using the JSON client parser.
var parseFn = DockerJsonClient.prototype.parse.call(self._api, req, cb);
parseFn(err, res);
DockerJsonClient.prototype.parse2.call(self._api, err, req, res, cb);
// Release the bulls!
res.resume();
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"bunyan": "1.x >=1.3.3",
"jws": "3.1.0",
"jwk-to-pem": "1.2.0",
"restify-clients": "^1.4.0",
"restify-clients": "^4.0.0",
"restify-errors": "^3.0.0",
"strsplit": "1.x",
"tough-cookie": "2.0.x",
Expand Down
145 changes: 0 additions & 145 deletions test/v1.dockerio.test.js

This file was deleted.

133 changes: 0 additions & 133 deletions test/v1.dockerio2redhatredir.test.js

This file was deleted.

Loading