Question

Comment puis-je faire un http passthrough protocole connectable pour le travail IE dans Firefox?

Sinon, comment développer un pour Firefox? Tous les exemples seraient appréciés.

Merci.

Était-ce utile?

La solution 2

Ecrire un objet XPCOM qui implémente nsIObserver. Ensuite, créez écouteur pour http-sur-demande et modifier http-sur-interroger-réponse.

var myObj = new MyObserver(); //implements nsIObserver
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.addObserver(myObj "http-on-modify-request",   false);
observerService.addObserver(myObj, "http-on-examine-response", false);

Autres conseils

Sur Firefox, si vous souhaitez contourner un comportement par défaut d'une manière "connectables", vous pouvez écrire un cette .

Avec un plugin NPAPI, vous avez accès à l'ensemble OS et sont donc libres d'exposer toutes les autres ressources à Firefox.

Ecrire un objet XPCOM qui implémente nsIProtocolHandler. Par exemple, vous pouvez accéder à des images locales à partir de pages web:

const Cu = Components.utils;
const Ci = Components.interfaces;
const Cm = Components.manager;
const Cc = Components.classes;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");+
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
/***********************************************************
class definition
***********************************************************/
function sampleProtocol() {
     // If you only need to access your component from JavaScript, 
     //uncomment   the following line:
     this.wrappedJSObject = this;
}   
sampleProtocol.prototype = {
classDescription: "LocalFile sample protocol",
classID:          Components.ID("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"),
contractID:       "@mozilla.org/network/protocol;1?name=x-localfile",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler]),
//interface nsIProtocolHandler
 allowPort :function(port, scheme)
 {
  if ((port == 80)&&(scheme == x-localfile)) {
   return true;
 }
 else
 {
     return false;
 }
},

newChannel: function(aURI)
{
    // Just example. Implementation must parse aURI
    var file = new FileUtils.File("D:\\temp\\getImage.jpg");
    var uri = NetUtil.ioService.newFileURI(file);
    var channel = NetUtil.ioService.newChannelFromURI(uri);
    return channel;
},
newURI(aSpec, aOriginCharset, aBaseURI)
{
    //URI looks like x-localfile://example.com/image1.jpg
    var uri = Cc["@mozilla.org/network/simple-uri;1"].createInstance(Ci.nsIURI);
    uri.spec = aSpec;
    return uri;
},
scheme: "x-localfile",
defaultPort: 80,
protocolFlags: 76
};
var components = [sampleProtocol];
if ("generateNSGetFactory" in XPCOMUtils)
var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);  //   Firefox 4.0 and higher
else
var NSGetModule = XPCOMUtils.generateNSGetModule(components);    // Firefox 3.x

Attention! Cette approche peut créer la vulnérabilité

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top