Re: Reference with baseref and absolute path
Jerome, So this leaves me wondering: Should getTargetRef() clear the baseref or do we have to rely on the verbose new Reference(getTargetRef().toString()) to do this ourselves ? It think we should fix the code as suggested by the Javadocs, unless I'm missing some other aspect. If all the unit tests pass after the change, then we should be pretty safe. Let's only change this in 1.1 branch only for now. = issue 473 : I generated the diff against the trunk - which is the 1.1 branch I assume And considering the request.getProtocol(): doesn't it make more sense to use the protocol of the targetref instead of the baseref when the targetref itself is absolute ? Yes, I think so. = issue 474 : same remark as above Kind regards, Jeroen DISCLAIMER http://www.schaubroeck.be/maildisclaimer.htm
RE: Reference with baseref and absolute path
Hi Jeroen, [...] I was expecting that calling getTargetRef() on a reference with an absolute path would clear the baseref. This is also how I understand it from the javadoc: This relative URI reference can then be resolved against a base reference via the getTargetRef() method which will return a new resolved Reference instance, an absolute URI reference with no base reference and with no dot-segments. Sounds like a bug to me. Further in the above get(reference) method, a Request is constructed, and request.getProtocol() gives an unexpected result: the implementation checks if there's a baseref, and returns this baseref's protocol. The fallback is to look at the protocol of the targetref itself. I would expect it to be just the other way around. In above scenario, dispatching of http://bar/foo.xml with base set to abc://foo/ would generate a request object that returns 'abc' as the protocol to use to get http://bar/foo.xml . Bug as well :( [...] So this leaves me wondering: Should getTargetRef() clear the baseref or do we have to rely on the verbose new Reference(getTargetRef().toString()) to do this ourselves ? It think we should fix the code as suggested by the Javadocs, unless I'm missing some other aspect. If all the unit tests pass after the change, then we should be pretty safe. Let's only change this in 1.1 branch only for now. If the last is the case, it is perhaps useful to provide a method like e.g. getCanonicalTargetRef() that gives the same result. And considering the request.getProtocol(): doesn't it make more sense to use the protocol of the targetref instead of the baseref when the targetref itself is absolute ? Yes, I think so. I'm of course willing to provide patches. Excellent, I'm looking forward to applying them. Make sure that you follow the contribution process indicated here: http://www.restlet.org/community/contribute Best regards, Jerome
Reference with baseref and absolute path
Hello, I'm using context.getClientDispatcher().get(reference) method for my source resolving needs. The reference itself is constructed by new Reference(baseref, path-that-could-be-absolute).getTargetRef(). When resolving relative paths, all is well, but when resolving absolute paths I have some issues. I was expecting that calling getTargetRef() on a reference with an absolute path would clear the baseref. This is also how I understand it from the javadoc: This relative URI reference can then be resolved against a base reference via the getTargetRef() method which will return a new resolved Reference instance, an absolute URI reference with no base reference and with no dot-segments. Further in the above get(reference) method, a Request is constructed, and request.getProtocol() gives an unexpected result: the implementation checks if there's a baseref, and returns this baseref's protocol. The fallback is to look at the protocol of the targetref itself. I would expect it to be just the other way around. In above scenario, dispatching of http://bar/foo.xml with base set to abc://foo/ would generate a request object that returns 'abc' as the protocol to use to get http://bar/foo.xml . I did a quick scan of the codebase for getClientDispatcher().get(reference), and noticed that the method with a reference-string as argument, getClientDispatcher().get(reference-string), is commonly used in favour of the former one. Indeed, when using the latter, a new reference is made whereby the baseref is cleared and my issue is solved. So this leaves me wondering: Should getTargetRef() clear the baseref or do we have to rely on the verbose new Reference(getTargetRef().toString()) to do this ourselves ? If the last is the case, it is perhaps useful to provide a method like e.g. getCanonicalTargetRef() that gives the same result. And considering the request.getProtocol(): doesn't it make more sense to use the protocol of the targetref instead of the baseref when the targetref itself is absolute ? I'm of course willing to provide patches. Kind regards, Jeroen DISCLAIMER http://www.schaubroeck.be/maildisclaimer.htm