Extension Auto-Installer, Wget replacement

Discussion related to extensions like Extension Auto-Installer or Google Search link fix.

Extension Auto-Installer, Wget replacement

Postby Andy » Mon Apr 29, 2013 4:47 am


I would like to send a file to Extension Auto-Installer, but not from wget, but from my nodejs script. As you may know, there are a tone of modules for nodejs that replicate the POST behavior. See for instance,

Unfortunately I couldn't make them work, here is a sample nodejs application,
Code: Select all
var request   = require('request');
var path      = require('path');
var fs        = require('fs');

var filepath = path.join(__dirname, 'myextension.xpi'); //path to xpi file

fs.createReadStream(filepath, {encoding: null}).pipe(request.post('http://localhost:8888'))

I am getting this error,
Code: Select all
Warning: WARN addons.xpi: Download failed: [Exception... "Component returned failure code: 0x8052000b (NS_ERROR_FILE_CORRUPTED) [nsIZipReader.open]"  nsresult: "0x8052000b (NS_ERROR_FILE_CORRUPTED)"  location: "JS frame :: resource://gre/modules/XPIProvider.jsm :: AI_loadManifest :: line 4555"  data: no]
Source file: resource://gre/modules/XPIProvider.jsm
Line: 4555

Any idea how to solve this? I think it is very useful to eliminate wget usage, especially for windows users.

Re: Extension Auto-Installer, Wget replacement

Postby Wladimir Palant » Sun Jul 07, 2013 9:39 am

The file has to be the entire request body, it shouldn't be encoded via multipart or such. From what I can tell, node.js allows doing it like this:

Code: Select all
var req = require("http").request({
  hostname: 'localhost',
  port: 8888,
  path: '/',
  method: 'POST'
}, function(res) {});

You need to read the file data first by usual means.
Wladimir Palant
ABP Developer
Posts: 8398
Joined: Fri Jun 09, 2006 6:59 pm
Location: Cologne, Germany

Return to Other extensions

Who is online

Users browsing this forum: No registered users and 3 guests