首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于Firefox的Http Passthrough Pluggable协议

用于Firefox的Http Passthrough Pluggable协议
EN

Stack Overflow用户
提问于 2009-11-04 05:56:27
回答 3查看 518关注 0票数 0

如何在Firefox中使用于IE的http通过可插拔协议工作?

或者,如何为Firefox开发一个?任何例子都将不胜感激。

谢谢。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2009-11-30 21:51:49

编写一个实现nsIObserver的XPCOM对象。然后为http-on-modify-request和http-on-examine response创建监听器。

代码语言:javascript
复制
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);
票数 0
EN

Stack Overflow用户

发布于 2009-11-15 19:33:29

在火狐上,如果你想以一种“可插拔”的方式绕过默认行为,你可以写一个NPAPI based plugin。假设关于这个主题的文档很少……但是要想让你开始,你可以咨询this

有了NPAPI插件,你就可以访问整个操作系统,因此可以自由地向Firefox公开任何其他资源。

票数 0
EN

Stack Overflow用户

发布于 2015-07-23 17:08:17

编写一个实现nsIProtocolHandler的XPCOM对象。例如,您可以从网页访问本地图像:

代码语言:javascript
复制
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

要小心!此方法可能会创建漏洞

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1670398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档