Skip to content

Commit

Permalink
Add "lib=js-x.x.xx" qs connectParam and X-Ably-Lib rest header
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonWoolf committed Jul 6, 2016
1 parent 0b35c46 commit c624fbd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions common/lib/transport/connectionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var ConnectionManager = (function() {
Utils.mixin(params, options.transportParams);
}
params.v = Defaults.apiVersion;
params.lib = Defaults.libstring;
return params;
};

Expand Down
3 changes: 2 additions & 1 deletion common/lib/util/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Defaults.TIMEOUTS = {
};
Defaults.httpMaxRetryCount = 3;

Defaults.version = '0.8.23';
Defaults.version = '0.8.23';
Defaults.libstring = 'js-' + Defaults.version;
Defaults.apiVersion = '0.8';

Defaults.getHost = function(options, host, ws) {
Expand Down
6 changes: 4 additions & 2 deletions common/lib/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ var Utils = (function() {
var accept = (format === 'json') ? contentTypes.json : contentTypes[format] + ',' + contentTypes.json;
return {
accept: accept,
'X-Ably-Version': Defaults.apiVersion
'X-Ably-Version': Defaults.apiVersion,
'X-Ably-Lib': Defaults.libstring
};
};

Expand All @@ -303,7 +304,8 @@ var Utils = (function() {
return {
accept: accept,
'content-type': contentType,
'X-Ably-Version': Defaults.apiVersion
'X-Ably-Version': Defaults.apiVersion,
'X-Ably-Lib': Defaults.libstring
};
};

Expand Down
6 changes: 5 additions & 1 deletion spec/rest/http.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@ define(['ably', 'shared_helper'], function(Ably, helper) {
var get_inner = Ably.Rest.Http.get;
Ably.Rest.Http.get = function (rest, path, headers, params, callback) {
test.ok(('X-Ably-Version' in headers), 'Verify version header exists');
test.ok(('X-Ably-Lib' in headers), 'Verify lib header exists');
test.equal(headers['X-Ably-Version'], Defaults.apiVersion, 'Verify current version number');
test.equal(headers['X-Ably-Lib'], 'js-' + Defaults.version, 'Verify libstring');
};

var post_inner = Ably.Rest.Http.post;
Ably.Rest.Http.post = function (rest, path, headers, body, params, callback) {
test.ok(('X-Ably-Version' in headers), 'Verify version header exists');
test.ok(('X-Ably-Lib' in headers), 'Verify lib header exists');
test.equal(headers['X-Ably-Version'], Defaults.apiVersion, 'Verify current version number');
test.equal(headers['X-Ably-Lib'], 'js-' + Defaults.version, 'Verify libstring');
};

//Call all methods that use rest http calls
test.expect(10);
test.expect(20);

rest.auth.requestToken();
rest.time();
Expand Down

0 comments on commit c624fbd

Please sign in to comment.