In readAllFromSocket, make outputData be a byte array to be consistent with other code.
Check return value from upcall for RESULT_REEXPRESS, RESULT_VERIFY (TODO) and RESULT_FETCHKEY (TODO).
diff --git a/js/Closure.js b/js/Closure.js
index 909c3c8..a06daad 100644
--- a/js/Closure.js
+++ b/js/Closure.js
@@ -26,6 +26,8 @@
 Closure.RESULT_REEXPRESS         =  1; // reexpress the same interest again
 Closure.RESULT_INTEREST_CONSUMED =  2; // upcall claims to consume interest
 Closure.RESULT_VERIFY            =  3; // force an unverified result to be verified
+Closure.RESULT_FETCHKEY          =  4; // get the key in the key locator and re-call the interest
+                                       //   with the key available in the local storage
 
 // Upcall kind
 Closure.UPCALL_FINAL              = 0; // handler is about to be deregistered
diff --git a/js/NDN.js b/js/NDN.js
index 5934cdd..05ab75a 100644
--- a/js/NDN.js
+++ b/js/NDN.js
@@ -187,28 +187,41 @@
     
     var encoder = new BinaryXMLEncoder();
 	interest.to_ccnb(encoder);	
-	var outputData = DataUtils.toString(encoder.getReducedOstream());
+	var outputData = encoder.getReducedOstream();
     encoder = null;
 		
 	var dataListener = {
-		onReceivedData : function(result) {
-			if (result == null || result == undefined || result.length == 0)
-				listener.onReceivedContentObject(null);
+		onReceivedData : function(data) {
+			if (data == null || data == undefined || data.length == 0)
+				dump("NDN.expressInterest: received empty data from socket.\n");
 			else {
-                var decoder = new BinaryXMLDecoder(result);	
+                var decoder = new BinaryXMLDecoder(data);	
                 var co = new ContentObject();
                 co.from_ccnb(decoder);
                    					
 				if(LOG>2) {
-					dump('DECODED CONTENT OBJECT\n');
+					dump("DECODED CONTENT OBJECT\n");
 					dump(co);
-					dump('\n');
+					dump("\n");
 				}
 					
                 // TODO: verify the content object and set kind to UPCALL_CONTENT.
 				var result = closure.upcall(Closure.UPCALL_CONTENT_UNVERIFIED,
                                new UpcallInfo(this, interest, 0, co));
-                // TODO: Check result for Closure.RESULT_OK, etc.          
+                if (result == Closure.RESULT_OK) {
+                    // success
+                }
+                else if (result == Closure.RESULT_ERR)
+                    dump("NDN.expressInterest: upcall returned RESULT_ERR.\n");
+                else if (result == Closure.RESULT_REEXPRESS)
+                    readAllFromSocket(this.host, this.port, outputData, dataListener);
+                else if (result == Closure.RESULT_VERIFY) {
+                    // TODO: force verification of content.
+                }
+                else if (result == Closure.RESULT_FETCHKEY) {
+                    // TODO: get the key in the key locator and re-call the interest
+                    //   with the key available in the local storage.
+                }
 			}
 		}
 	}
diff --git a/js/NDNSocketTransportService.js b/js/NDNSocketTransportService.js
index 5fe86aa..76ab50e 100644
--- a/js/NDNSocketTransportService.js
+++ b/js/NDNSocketTransportService.js
@@ -9,25 +9,25 @@
 // Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 // Components.utils.import("resource://gre/modules/NetUtil.jsm");
 
-/** Send outputData to host:port, read the entire response and call listener.onReceivedData(data)
- *    where data is a byte array.
+/** Send outputData (byte array) to host:port, read the entire response and call 
+ *    listener.onReceivedData(data) where data is a byte array.
  *  Code derived from http://stackoverflow.com/questions/7816386/why-nsiscriptableinputstream-is-not-working .
  */
 function readAllFromSocket(host, port, outputData, listener) {
 	var transportService = Components.classes["@mozilla.org/network/socket-transport-service;1"].getService
-	(Components.interfaces.nsISocketTransportService);
+        (Components.interfaces.nsISocketTransportService);
 	var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].createInstance
-	(Components.interfaces.nsIInputStreamPump);
+        (Components.interfaces.nsIInputStreamPump);
 	var transport = transportService.createTransport(null, 0, host, port, null);
 	var outStream = transport.openOutputStream(1, 0, 0);
-	outStream.write(outputData, outputData.length);
+    var rawDataString = DataUtils.toString(outputData);
+	outStream.write(rawDataString, rawDataString.length);
 	outStream.flush();
 	var inStream = transport.openInputStream(0, 0, 0);
 	var dataListener = {
 		data: [],
         structureDecoder: new BinaryXMLStructureDecoder(),
 		calledOnReceivedData: false,
-        debugNOnDataAvailable: 0,
 		
 		onStartRequest: function (request, context) {
 		},
@@ -45,7 +45,6 @@
                 return;
             
 			try {
-                this.debugNOnDataAvailable += 1;
 				// Ignore _inputStream and use inStream.
 				// Use readInputStreamToString to handle binary data.
 				var rawData = NetUtil.readInputStreamToString(inStream, count);