Closed
Bug 296798
Opened 19 years ago
Closed 19 years ago
invalid nsIURI creating
Categories
(Core :: Networking, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: surkov, Assigned: darin.moz)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; ru-RU; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 (ax) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b) Gecko/20050217 var ioservice=Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); var protocol=ioservice.getProtocolHandler("file"); var uri=protocol.newURI(url, null, null); var channel=protocol.newChannel(uri); Works fine. When I create uri as follows then newChannel() method throws exception NO_INTERFACE. var nsiuri = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI); nsiuri.spec=url; At first glance uri and nsiuri look identically. Reproducible: Always
Reporter | ||
Comment 1•19 years ago
|
||
Note uri.equals(nsiuri) is false
Comment 2•19 years ago
|
||
Creating a standard-url;1 and setting spec is not the correct way to create a URI. You must use the IO Service to create URIs normally, like this: var uri = ioservice.newURI(url, "uricharset", null); I think this bug is INVALID.
Comment 3•19 years ago
|
||
>
Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
don't do that.
in fact don't even do that:
>var protocol=ioservice.getProtocolHandler("file");
>var uri=protocol.newURI(url, null, null);
The right way to create URIs is:
var uri = ioservice.newURI(uri, charset, baseURI);
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Comment 4•19 years ago
|
||
(the getProtocolHandler method will work, it's not strictly wrong. so, you could do that, I guess. but easier is to just call newURI on the IO service.)
Reporter | ||
Comment 5•19 years ago
|
||
What the difference between nsIURI of "@mozilla.org/network/standard-url;1" and ioservice.newURI()? Is ioservice.newURI() realzided by other component (not "@mozilla.org/network/standard-url;1")?
Assignee | ||
Comment 6•19 years ago
|
||
> What the difference between nsIURI of "@mozilla.org/network/standard-url;1" > and ioservice.newURI()? nsIIOService::newURI delegates to nsIProtocolHandler::newURI for the nsIProtocolHandler corresponding to the URI scheme. > Is ioservice.newURI() realzided by other component (not > "@mozilla.org/network/standard-url;1")? Yes The ContractID "@mozilla.org/network/standard-url;1" should _only_ be used to implement nsIProtocolHandler::newURI.
Reporter | ||
Comment 7•19 years ago
|
||
(In reply to comment #6) > nsIIOService::newURI delegates to nsIProtocolHandler::newURI for the > nsIProtocolHandler corresponding to the URI scheme. > > The ContractID "@mozilla.org/network/standard-url;1" should _only_ be used to > implement nsIProtocolHandler::newURI. That is contractid "@mozilla.org/network/standard-url;1" is used to create nsIURI by nsIIOService. I don't understand what special nsIProtocolHandler do with contractid "@mozilla.org/network/standard-url;1". If you explanation that my bug is invalid is "just don't do it" that mark bug as verified.
Comment 9•19 years ago
|
||
>That is contractid "@mozilla.org/network/standard-url;1" is used to create
>nsIURI by nsIIOService. I don't understand what special nsIProtocolHandler do
>with contractid "@mozilla.org/network/standard-url;1".
Protocol handlers need not use that contract ID at all. The URI implementation
may not have an associated contract id. The Initialization used by the protocol
handler may not be available via an XPCOM interface. etc.
For example: The file protocol handler initializes the URI in a way that it
implements nsIFileURI. Just creating an instance of standard-url won't do that.
You need to log in
before you can comment on or make changes to this bug.
Description
•