Opened 11 years ago

Closed 10 years ago

#8928 closed defect (fixed)

JsonRest Location Header Not Evaluated in Sync Mode

Reported by: Jarrod Carlson Owned by: Kris Zyp
Priority: high Milestone: 1.4
Component: Dojox Version: 1.3.0b3
Keywords: jsonrest rpc jsonreststore Cc:
Blocked By: Blocking:

Description

While unit testing my REST Service, I noticed that the dojox.rpc.JsonRest? is not processing the Location header on creation of new store items.

This issue affects at least Dojo 1.3.0rc1 in Firefox 3; perhaps other versions as well.

The issue us that the Deferred callback in dojox.rpc.JsonRest? lines 123-145 is not executed when the store is set to sync mode = true.

Here is the callback in dojox.rpc.JsonRest?:

123	dfd.addCallback(function(value){
124		try{
125			// Implements id assignment per the HTTP specification
126			var newId = dfd.ioArgs.xhr && dfd.ioArgs.xhr.getResponseHeader("Location");
127			//TODO: match URLs if the servicePath is relative...
128			if(newId){
129				// if the path starts in the middle of an absolute URL for Location, we will use the just the path part 
130				var startIndex = newId.match(/(^\w+:\/\/)/) && newId.indexOf(service.servicePath);
131				newId = startIndex > 0 ? newId.substring(startIndex) : (service.servicePath + newId).
132						// now do simple relative URL resolution in case of a relative URL. 
133						replace(/^(.*\/)?(\w+:\/\/)|[^\/\.]+\/\.\.\/|^.*\/(\/)/,'$2$3');
134				object.__id = newId;
135				Rest._index[newId] = object;
136			}
137			value = resolveJson(service, dfd, value, object && object.__id);
138		}catch(e){}
139		if(!(--left)){
140			if(kwArgs.onComplete){
141				kwArgs.onComplete.call(kwArgs.scope);
142			}
143		}
144		return value;
145	});

When step-debugging through the code, on reaching line 123, the the Deferred object claims to have not been fired, yet I can see in Firebug that the request has been made.

Because this callback does not execute, the JsonRestStore? is unable to update the new item with appropriate details (such as the server-assigned ID).

If it helps, I can provide some sample code, but I don't think my code is to blame at this point - the issue is resolved by setting the store to sync = false.

Change History (2)

comment:1 Changed 11 years ago by Adam Peller

Owner: changed from Adam Peller to Kris Zyp

comment:2 Changed 10 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

(In [18461]) Apply syncMode setting to commit, fixes #8928

Note: See TracTickets for help on using tickets.