cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ellen <ellenxiao0...@163.com>
Subject The logic of Response getAllLinks method is not good?
Date Tue, 28 Apr 2015 06:19:54 GMT
Hi all,

I'm using response getLink method from CXF.

The code is:

    private Map<String, Link> getAllLinks() {
        List linkValues = metadata.get(HttpHeaders.LINK);
        if (linkValues == null) {
            return Collections.emptyMap();
        } else {
            Map<String, Link> links = new LinkedHashMap<String, Link>();
            for (Object o : linkValues) {
                Link link = o instanceof Link ? (Link)o :
Link.valueOf(o.toString());
                if (!link.getUri().isAbsolute()) {
                    *URI requestURI =
URI.create((String)outMessage.get(Message.REQUEST_URI));*
                    link = Link.fromLink(link).baseUri(requestURI).build();
                }
                links.put(link.getRel(), link);
            }
            return links;
        }
    }

But from the code you can see therequestURI comes from Message REQUEST_URI.

If my request uri is http://www.test.com/resource/get

then I continue use the link to invoke like this:

Link link = response.getLink(linkName);
response = client.invocation(link).post(null);

The url which response use is joined like this:
http://www.test.com/resource/get/post,

but this http://www.test.com/resource/get/post is not exist (correct lin
should be http://www.test.com/resource/post). So I think this is not good.

I'm looking at Jersey getLink method, and found they use:
URI result = baseUri.resolve(refUri);

to get Request url, and I found the result is correct for me.

Could you please take a look this issue?

Thanks a lot!



--
View this message in context: http://cxf.547215.n5.nabble.com/The-logic-of-Response-getAllLinks-method-is-not-good-tp5756610.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Mime
View raw message