Skip to content

Wrong hadnling of 302 redirects #28

Open
@oaleynik

Description

@oaleynik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions