Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong hadnling of 302 redirects #28

Open
oaleynik opened this issue Sep 2, 2013 · 0 comments
Open

Wrong hadnling of 302 redirects #28

oaleynik opened this issue Sep 2, 2013 · 0 comments

Comments

@oaleynik
Copy link

oaleynik commented Sep 2, 2013

Hi everybody,

To describe this issue let's start from official Read API docs: https://build.phonegap.com/docs/read_api

For example the GET https://build.phonegap.com/api/v1/apps/:id/icon method contains the description of two different behaviors:

"In the successful case, this API method will return a 302 redirect to the icon file - the actual body of the response will point to the resource in question"

That means, that if we will follow the 302 redirect, than we will recieve the actual icon data, in other case - we should get the object with the location field, which points to the requested resource.

{
    "location":"http://s3.amazonaws.com/build.phonegap.com/some-long-guid/icon.png"
}

Currently, if we pass the followRedirect: false to API call, than we get the response in err parameter of callback, wrapped into Error object. So, considering the next example:

api.get(path, {followRedirect: false}, function(err, data) {
     return cb(err, data);
});

... we will get the undefined data param, and [Error: "{location: "..."}"] in error param.

Link to the root of issue: https://github.com/phonegap/node-phonegap-build-api/blob/master/lib/api.js#L208

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant