Closed dwbuildmgr closed 10 years ago
Following is an example addressing both options (and without obviously generalizing it):
/ get file size (necessary for multipart upload) fs.stat(filepath, function(err, stats) { if (err) { grunt.fail.warn('Error: ' + err); done(err); } else if (stats.isFile()) { var fileSize = stats.size; grunt.log.writeln('Uploading "' + filepath + '" as "' + field + '"'); // build request data (because of dynamic key in data object) var reqData = options.data || {}; reqData[field] = rest.file(filepath, null, fileSize, null, null); // HTTP request rest.request(options.url, { method: options.method, headers: options.headers, multipart: true, data: reqData, rejectUnauthorized: false }).on('complete', function(data, response) { if (response instanceof Error) { grunt.log.writeln("response.message"); } if (response == null) {grunt.log.writeln('no response');} grunt.log.writeln('Status Code' + response.statusCode); if (response.statusCode >= 200 && response.statusCode < 300) { grunt.log.ok('Upload successful of "' + filepath + '" as "' + field + '" - ' + options.method + ' @ ' + options.url); } else { grunt.fail.warn('Failed uploading "' + filepath + '" as "' + field + '" (status code: ' + response.statusCode + ') - ' + options.method + ' @ ' + options.url); } // callback once upload is done done(data); }).on('error', function(err, response){ grunt.log.writeln("error" + err); });
Hey, Thanks, I'll look into it. Do you have any example of publicly accessible SSL server with no valid certificate, so I can test?
I do but would much prefer to email to you as they are corporate servers. My email address is jmoody at demandware.com Perhaps we could just quickly exchange an email.
Hey, sorry for the blackout. I'm about to accept PR #7. Do you think it'd solve your issue?
Fixed with #7.
Restler has a method called rejectUnauthorized for times when the error message "errorError: Hostname/IP doesn't match certificate's altnames." This is not accessible set even. I can just add this to the grunt file via the options.
Could you
1) Allow rejectUnauthorized (boolean) to be set in options. 2) Can you add error handling such that this error is caught.