Poor example code
The example code pointed to from here, http://www.nexgenmedia.net/docs/protocol/ has several problems
defaultSearchURLis being modified on line 102 without having been declared.
- On line 119 the code seems to be designed to continue even if it fails to read the preference. In fact running it throws this exception: [Search Protocol failed to get the search pref: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.getComplexValue]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: file:///.../testprotocol.js :: anonymous :: line 103" data: no]]
- If you do create the preference (though no example for its value is given), this exception is thrown: [Search Protocol failed to get the search pref: TypeError: Components.classes['@mozilla.org/rdf/datasource;1?name=internetsearch'] is undefined]
It looks like it's far from straightforward to implement nsIProtocolHandler and especially nsIHttpChannel for a newcomer, in any language! The nsIChannel is not mentioning it's inheriting from nsIRequest, and the nsIRequest page is missing by the way. The NSGetModule page also hasn't been written, but is linked to from nsGetModuleProc. — StijnSanders 2008-11-05