Closed lookaflyingdonkey closed 11 years ago
@bigclick could you provide me that example which caused an error, while the 201 header is something that is a response header, not a header that needs to be sent to make it work. The example on www.awssum.io on Route53.CreateHostedZone works without this change and I don't understand why this needs to be added to make it work. Hope you could provide that example or reproduce it with the awssum.io-example, so I could further investigate what is causing your error.
Hey,
I am running the same example from the docs and getting the following output without my modification
Error : { StatusCode: 201,
Headers:
{ 'x-amzn-requestid': '74680544-5a4a-11e2-a117-eb4e7251f0ec',
location: 'https://route53.amazonaws.com/2011-05-05//hostedzone/ZA6EN5I9M8JYB',
'content-type': 'text/xml',
'content-length': '746',
date: 'Wed, 09 Jan 2013 10:51:00 GMT' },
Body:
{ CreateHostedZoneResponse:
{ '@': { xmlns: 'https://route53.amazonaws.com/doc/2011-05-05/' },
HostedZone:
{ Id: '/hostedzone/ZA6EN5I9M8JYB',
Name: 'newdomain2.com.',
CallerReference: 'unique_string_to_ensure_action_will_not_be_called_twice_12345',
Config: { Comment: 'Created a new hosted zone.' } },
ChangeInfo:
{ Id: '/change/C1WNP38YRJLR2L',
Status: 'PENDING',
SubmittedAt: '2013-01-09T10:51:00.231Z' },
DelegationSet:
{ NameServers:
{ NameServer:
[ 'ns-2041.awsdns-63.co.uk',
'ns-1364.awsdns-42.org',
'ns-646.awsdns-16.net',
'ns-11.awsdns-01.com' ] } } } } }
Data : null
Whereas with my addition it is giving
Error : null
Data : { StatusCode: 201,
Headers:
{ 'x-amzn-requestid': '49c45732-5a4a-11e2-a117-eb4e7251f0ec',
location: 'https://route53.amazonaws.com/2011-05-05//hostedzone/ZC2EXRS5TUR6C',
'content-type': 'text/xml',
'content-length': '745',
date: 'Wed, 09 Jan 2013 10:49:48 GMT' },
Body:
{ CreateHostedZoneResponse:
{ '@': { xmlns: 'https://route53.amazonaws.com/doc/2011-05-05/' },
HostedZone:
{ Id: '/hostedzone/ZC2EXRS5TUR6C',
Name: 'newdomain.com.',
CallerReference: 'unique_string_to_ensure_action_will_not_be_called_twice_1234',
Config: { Comment: 'Created a new hosted zone.' } },
ChangeInfo:
{ Id: '/change/C3NNBZ63HCHGSX',
Status: 'PENDING',
SubmittedAt: '2013-01-09T10:49:48.703Z' },
DelegationSet:
{ NameServers:
{ NameServer:
[ 'ns-692.awsdns-22.net',
'ns-1657.awsdns-15.co.uk',
'ns-1411.awsdns-48.org',
'ns-353.awsdns-44.com' ] } } } } }
It looks like it is coming from awssum.js line 849
if ( ! isStatusCodeOk(statusCode, res.statusCode) ) {
which then gets the default set on line 303
AwsSum.prototype.statusCode = function(options) {
return 200;
};
and then at the beginning of the response being processed the code on line 604 does
var statusCode = operation.statusCode || self.statusCode();
So in this case where it returns 201 as the header it wont validate in the isStatusCodeOk function against the default 200 and then it will fire the callback as callback(result, null) instead of callback(null, result)
Or any I missing something completely?
Cheers, Dean
Thank you, am seeing your error and have merged it. Thanks a lot!
Route 53 CreateHostedZone returns a 201 Created header code instead of the standard 200 OK, this was causing the call to return an error