Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Freemius.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ class Freemius {

};

// For binary downloads (like .zip files), set encoding to null
if (pCanonizedPath.endsWith('.zip')) {
options.encoding = null;
}

let content_type = 'application/json';
let json_encoded_params = empty(pParams) ? '' : JSON.stringify(pParams);

Expand Down Expand Up @@ -414,8 +419,9 @@ class Freemius {
request(options, function (error, response, body) {
//console.log(error);
//console.log(response);
if (!error && response.statusCode == 200) {
responseCallback(response.body);
// Accept any 2xx status code as success (200-299)
if (!error && response.statusCode >= 200 && response.statusCode < 300) {
responseCallback(response.body || '');

} else {
console.log("Error:Stats Code:"+response.statusCode);
Expand Down Expand Up @@ -454,8 +460,9 @@ class Freemius {
data +=
('--' + pBoundary + os.EOL) +
(`Content-Disposition: form-data; name="${name}"; filename="${filename}"` + os.EOL) +
(`Content-Type: ${this.GetMimeContentType(file_path)}` + os.EOL);

(`Content-Type: ${this.GetMimeContentType(file_path)}` + os.EOL) +
os.EOL;

content = fs.readFileSync(file_path);
}

Expand Down