Did you know about the handy NetUtil object available when you import NetUtil.jsm? I bet you didn’t since it’s fairly new! There’s no MDC page yet, but the API is getting even better. Bug 508902 added a new method on NetUtil to create nsIURI objects. NetUtil will cache the IO Service so the calling site doesn’t have to. As more code starts to use this, fewer objects will have to cache the IO Service themselves.
The API mirrors nsIOService‘s
3 replies on “New API Added on NetUtil”
The last two arguments have always been optional, afaik, regardless of what some callers did.
There’s also a makeURI function that can be used in the browser.xul scope.
I checked what ioService API I’m using – mostly newURI of course but also newChannel and newFileURI. Particularly for that latter a wrapper that accepts both nsIFile and plain path strings would be nice.