Status

()

Core
Networking
VERIFIED INVALID
13 years ago
13 years ago

People

(Reporter: surkov, Assigned: Darin Fisher)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

13 years ago
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

13 years ago
Note uri.equals(nsiuri) is false

Comment 2

13 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.
>
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
Last Resolved: 13 years ago
Resolution: --- → INVALID
(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

13 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

13 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

13 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.
(Assignee)

Comment 8

13 years ago
Verified Invalid
Status: RESOLVED → VERIFIED
>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.