Opened 15 years ago

Closed 15 years ago

#1323 closed defect (fixed)

hostenv_rhino.js: dojo.hostenv.loadUri and readText don't handle URLs

Reported by: [email protected] Owned by: Adam Peller
Priority: high Milestone:
Component: BuildTools Version: 0.3
Keywords: Cc:
Blocked By: Blocking:


dojo.hostenv.loadUri contains the following line:


There is no such thing as; that should be

Later on in the same file, the readText function only looks for a local file. It would be useful (and consistent) if it behaved like dojo.hostenv.loadUri and loaded resources via URL, too. The following code would do just that:

function readText(uri){
	// NOTE: we intentionally avoid handling exceptions, since the caller will
	// want to know
	var sb = new java.lang.StringBuffer();
	var reader;
	try {
		// try loading it as an external resource first
		reader = new;
	catch (e) {
 		// fallback on loading it as a local file
 		reader = new;
	var input = new;
	var line = "";
	while((line = input.readLine()) != null){
	return sb.toString();

Change History (3)

comment:1 Changed 15 years ago by guest

Summary: hostenv_rhino: dojo.hostenv.loadUri and readText don't handle URLshostenv_rhino.js: dojo.hostenv.loadUri and readText don't handle URLs

comment:2 Changed 15 years ago by Adam Peller

Owner: changed from alex to Adam Peller

I fixed the reference and tried to implement uri and local uri loading in r5009. Please re-open if that doesn't work for you or you think improvements can still be made. I also tried to accomodate explicit UTF-8 encoding as well as the new loadUri arguments. I would have liked to just use the new built-in Rhino features to read uris and files, but that's a 1.6 thing. Perhaps we can put in something so it uses that feature if it's available?

comment:3 Changed 15 years ago by Adam Peller

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.