Request Clone - Change URI

Poster Content
nk4um User
Posts: 79
March 7, 2010 16:51Request Clone - Change URI
There is no immediate need given your suggested work around (Thank you).

The scenario is when you want to fork a process into separate threads of work (via subrequests) and you want to clone the existing requests (verb, parameters, headers, primary representation) but obviously just need to change the URI.
nk4um Moderator
Posts: 485
March 7, 2010 15:21
Hi Jeremy,
yes it could. The INKFRequest interface used to have a setIdentifier() method but that was removed because of the issues wrt to constructing requests targeting endpoints and the valid that does against the endpoint interface specification. Your suggested method of:
INKFRequest INKFRequestReadOnly.createIssuableClone(String aIdentifier)

would work. What are you timescales for needed this enhancement? As a workaround you can use the code inside the method to achieve the same result:
NKFRequestImpl req= (NKFRequestImpl)mContext.createRequest(this.getIdentifier());
req.setVerb(this.getVerb());
req.setRepresentationClass(this.getRepresentationClass());
INKFResponseReadOnly primaryResponse = this.getPrimaryAsResponse();
if (primaryResponse!=null)
{   req.addPrimaryArgumentFromResponse(primaryResponse);
}
IRequestResponseFields headers=mRequest.getHeaders();
for (int i=0; i<headers.size(); i++)
{   req.setHeader(headers.getKey(i), headers.getValue(i), headers.isSticky(i));
}

Cheers, Tony
nk4um User
Posts: 79
March 7, 2010 02:11Request Clone - Change URI
The API allows you to clone the existing request and update the verb.

INKFRequest request =  context.getThisRequest().getIssuableClone();


But the does not allow you to change the URI. Could this be added to the API?
For example:


String uri = "res:/blah/foo"
INKFRequest request =  context.getThisRequest().getIssuableClone(uri)