Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated the User-Agent string.

  • Loading branch information...
commit 71b29efecadf71c2498d4a6b8dbcdedf250d92f9 1 parent 4f053fd
@trevorrowe trevorrowe authored
View
2  lib/http.js
@@ -43,7 +43,7 @@ AWS.HttpRequest = inherit({
this.method = 'POST';
this.path = '/';
this.headers = {};
- this.headers['User-Agent'] = 'aws-sdk-js/' + AWS.VERSION;
+ this.headers['User-Agent'] = AWS.util.userAgent();
this.body = undefined;
this.endpoint = undefined;
this.region = undefined;
View
8 lib/util.js
@@ -32,6 +32,14 @@ var cryptoLib = require('crypto');
*/
AWS.util = {
+ engine: function enc() {
+ return process.platform + '/' + process.version;
+ },
+
+ userAgent: function userAgent() {
+ return 'aws-sdk-nodejs/' + AWS.VERSION + AWS.util.engine();
+ },
+
uriEscape: function uriEscape(string) {
/*jshint undef:false */
var uri = escape(string).replace(/\+/g, '%2B').replace(/\//g, '%2F');
View
3  test/unit/http_request.spec.coffee
@@ -28,8 +28,7 @@ describe 'AWS.HttpRequest', ->
expect(request.path).toEqual('/')
it 'provides headers with a default user agent', ->
- userAgent = 'aws-sdk-js/' + AWS.VERSION
- expect(request.headers).toEqual({ 'User-Agent': userAgent })
+ expect(request.headers).toEqual({ 'User-Agent': AWS.util.userAgent() })
it 'defaults body to undefined', ->
expect(request.body).toEqual(undefined)
View
5 test/unit/sigv4.spec.coffee
@@ -14,6 +14,9 @@
AWS = require('../../lib/core')
require('../../lib/services/dynamodb')
+beforeEach ->
+ spyOn(AWS.util, 'userAgent').andReturn('aws-sdk-js/0.1')
+
buildRequest = ->
ddb = new AWS.DynamoDB.Client({ region:'region' })
req = ddb.buildRequest('listTables', { foo: 'bar' })
@@ -84,7 +87,7 @@ describe 'AWS.SigV4', ->
'content-type:application/x-amz-json-1.0',
'date:' + datetime,
'host:localhost',
- 'user-agent:aws-sdk-js/' + AWS.VERSION,
+ 'user-agent:' + AWS.util.userAgent(),
'x-amz-date:' + datetime,
'x-amz-security-token:session',
'x-amz-target:DynamoDB_20111205.ListTables'
Please sign in to comment.
Something went wrong with that request. Please try again.